diff --git a/event/common.go b/event/common.go index 4778201..8e93783 100644 --- a/event/common.go +++ b/event/common.go @@ -34,6 +34,11 @@ const ( SendMessageToPeer = Type("SendMessageToPeer") NewMessageFromPeer = Type("NewMessageFromPeer") + // attributes: + // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"] + // Error: string describing the error + SendMessageToPeerError = Type("SendMessageToPeerError") + // REQUESTS TO STORAGE ENGINE // a peer contact has been added diff --git a/protocol/connections/engine.go b/protocol/connections/engine.go index d5a82d9..795e393 100644 --- a/protocol/connections/engine.go +++ b/protocol/connections/engine.go @@ -85,9 +85,10 @@ func (e *Engine) eventHandler() { case event.SendMessageToPeer: log.Debugf("Sending Message to Peer.....") ppc := e.connectionsManager.GetPeerPeerConnectionForOnion(ev.Data[event.RemotePeer]) - if ppc != nil { - // TODO this will block. + if ppc != nil && ppc.GetState() == AUTHENTICATED { ppc.SendPacket([]byte(ev.Data[event.Data])) + } else { + e.eventManager.Publish(event.NewEvent(event.SendMessageToPeerError, map[event.Field]string{event.RemotePeer: ev.Data[event.RemotePeer], event.Error: "peer is offline or the connection has yet to finalize"})) } case event.BlockPeer: e.blocked.Store(ev.Data[event.RemotePeer], true) diff --git a/protocol/connections/peerserverconnection.go b/protocol/connections/peerserverconnection.go index f22da2a..c567e20 100644 --- a/protocol/connections/peerserverconnection.go +++ b/protocol/connections/peerserverconnection.go @@ -135,6 +135,5 @@ func (psc *PeerServerConnection) Close() { // HandleGroupMessage passes the given group message back to the profile. func (psc *PeerServerConnection) HandleGroupMessage(gm *protocol.GroupMessage) { - log.Debugf("Received Group Message") psc.GroupMessageHandler(psc.Server, gm) }