From 4051c0333f43765a7414a4e0e8ac51e7148b0646 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Dec 2014 13:23:11 +0100 Subject: Added whisper js api --- ui/qt/qwhisper/message.go | 4 ++-- ui/qt/qwhisper/whisper.go | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go index 07505ba09..c87647399 100644 --- a/ui/qt/qwhisper/message.go +++ b/ui/qt/qwhisper/message.go @@ -8,7 +8,7 @@ import ( type Message struct { ref *whisper.Message - Flags byte + Flags int32 Payload string From string } @@ -16,7 +16,7 @@ type Message struct { func ToQMessage(msg *whisper.Message) *Message { return &Message{ ref: msg, - Flags: msg.Flags, + Flags: int32(msg.Flags), Payload: ethutil.Bytes2Hex(msg.Payload), From: ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())), } diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 6fb00cdac..62676daf5 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -33,9 +33,9 @@ func (self *Whisper) SetView(view qml.Object) { self.view = view } -func (self *Whisper) Post(data string, to, from string, topics []string, pow, ttl uint32) { +func (self *Whisper) Post(data, to, from string, topics []string, priority, ttl uint32) { msg := whisper.NewMessage(fromHex(data)) - envelope, err := msg.Seal(time.Duration(pow), whisper.Opts{ + envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ Ttl: time.Duration(ttl), To: crypto.ToECDSAPub(fromHex(to)), From: crypto.ToECDSA(fromHex(from)), @@ -64,13 +64,14 @@ func (self *Whisper) HasIdentity(key string) bool { func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { filter := filterFromMap(opts) + var i int filter.Fn = func(msg *whisper.Message) { if view != nil { - view.Call("onMessage", ToQMessage(msg)) + view.Call("onShhMessage", ToQMessage(msg), i) } } - i := self.Whisper.Watch(filter) + i = self.Whisper.Watch(filter) self.watches[i] = &Watch{} return i -- cgit v1.2.3