예제 #1
0
 void OnPresenceMessage(ForwardPresenceMessage message)
 {
     SerializationHelper.Deserialize <Squiggle.Core.Presence.Transport.Message>(message.Message, msg =>
     {
         var args = new PresenceMessageForwardedEventArgs(msg, message.BridgeEndPoint);
         PresenceMessageForwarded(this, args);
     }, "presence message");
 }
예제 #2
0
        void bridgeHost_PresenceMessageForwarded(object sender, PresenceMessageForwardedEventArgs e)
        {
            if (e.Message.ChannelID == presenceChannel.ChannelID)
            {
                return;                                    // my own message
            }
            if (!targetBridges.Contains(e.BridgeEndPoint)) // not coming from a target bridge list
            {
                return;
            }

            messageInspector.InspectForeignPresenceMessage(e.Message, e.BridgeEndPoint);

            Trace.WriteLine("Replay: " + e.Message.GetType().Name);

            if (e.IsBroadcast)
            {
                ExceptionMonster.EatTheException(() =>
                {
                    presenceChannel.MulticastMessage(e.Message);
                }, "replaying presence message to local clients");
            }
            else
            {
                ExceptionMonster.EatTheException(() =>
                {
                    IPEndPoint endpoint = routeTable.GetLocalPresenceEndPoint(e.Message.Recipient.ClientID);

                    if (endpoint != null)
                    {
                        e.Message.Recipient = new SquiggleEndPoint(e.Message.Recipient.ClientID, endpoint);
                        presenceChannel.SendMessage(e.Message);
                    }
                }, "routing presence message to local user");
            }
        }