Exemplo n.º 1
0
        private void _SendDataFromChannel(UDPManagerEvent e)
        {
            object data = new { UDPMSID = e.UDPdataInfo.ID, UDPMCN = e.UDPdataInfo.ChannelName, UDPMRA = (e.Target as UDPChannel).GuarantiesDelivery, data = e.UDPdataInfo.Data };

            this._ClassicSend(data, e.UDPdataInfo.RemoteAddress, e.UDPdataInfo.RemotePort);
            this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_SENT, e.UDPdataInfo));
        }
Exemplo n.º 2
0
 private void _Listening(UDPManagerEvent e)
 {
     if (this._serverAddress != null && this._serverPort > 0)
     {
         this.Connect(this._serverAddress, this._serverPort);
     }
     this.DispatchEvent(e);
 }
Exemplo n.º 3
0
 private void _CancelHandler(UDPManagerEvent e)
 {
     if (e.UDPdataInfo.ChannelName.Substring(0, 7) == UDPManager._UDPMRCP && e.UDPdataInfo.Data.messageType.ToString() == "ping")
     {   //implements time out feature
         UDPPeer peer = this._peers.Where(a => a.Address == e.UDPdataInfo.RemoteAddress).Where(a => a.Port == e.UDPdataInfo.RemotePort).FirstOrDefault();
         this.KickClient(peer);
         this.DispatchEvent(new UDPServerEvent(UDPServerEvent.Names.CLIENT_TIMED_OUT, peer));
     }
     else
     {
         this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_CANCELED, e.UDPdataInfo));      //redispatch
     }
 }
Exemplo n.º 4
0
 private void _DeliveryHandler(UDPManagerEvent e)
 {
     if (e.UDPdataInfo.ChannelName.Substring(0, 7) == UDPManager._UDPMRCP && e.UDPdataInfo.Data.messageType.ToString() == "ping")
     {   //implements ping feature
         UDPPeer peer = this._peers.Where(a => a.Address == e.UDPdataInfo.RemoteAddress).Where(a => a.Port == e.UDPdataInfo.RemotePort).FirstOrDefault();
         peer.StartPingTimer();
         peer.SetPing(e.UDPdataInfo.Ping);
         this.DispatchEvent(new UDPServerEvent(UDPServerEvent.Names.CLIENT_PONG, peer));
     }
     else
     {
         this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_DELIVERED, e.UDPdataInfo));     //redispatch
     }
 }
Exemplo n.º 5
0
        //
        //private methods
        //

        private void _ReceivedDataHandler(UDPManagerEvent e)
        {
            if (e.UDPdataInfo.ChannelName.Substring(0, 7) == UDPManager._UDPMRCP && e.UDPdataInfo.Data["messageType"].ToString() == "ping")
            {
                //certainly do nothin
            }
            else
            {
                if (this._udpServer != null && this._udpServer.Address == e.UDPdataInfo.RemoteAddress && this._udpServer.Port == e.UDPdataInfo.RemotePort)
                {
                    this.DispatchEvent(new UDPClientEvent(UDPClientEvent.Names.SERVER_SENT_DATA, this._udpServer, e.UDPdataInfo));
                }
                this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_RECEIVED, e.UDPdataInfo));
            }
        }
Exemplo n.º 6
0
 private void _CancelHandler(UDPManagerEvent e)
 {
     if (e.UDPdataInfo.ChannelName == UDPManager._UDPMRCP && e.UDPdataInfo.Data.messageType.ToString() == "ping")
     {
         this.DispatchEvent(new UDPClientEvent(UDPClientEvent.Names.SERVER_TIMED_OUT, this._udpServer));
         this.Close();
     }
     else if (e.UDPdataInfo.ChannelName == UDPManager._UDPMRCC && e.UDPdataInfo.Data.messageType.ToString() == "newConnection")
     {
         this.DispatchEvent(new UDPClientEvent(UDPClientEvent.Names.CONNECTION_FAILED, null));
         this.Close();
     }
     else
     {
         this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_CANCELED, e.UDPdataInfo));
     }
 }
Exemplo n.º 7
0
 private void _CancelNotifForward(UDPManagerEvent e)
 {
     if (e.UDPdataInfo.ChannelName.Length >= 8 && e.UDPdataInfo.ChannelName.Substring(0, 8) == UDPManager._UDPMRCP + ":")
     {
         int max = this._receivedIDs.Count;
         for (int i = 0; i < max; i++)
         {
             string[] ar = _receivedIDs[i].Split(',');
             if (ar[0].Split(':')[0] == e.UDPdataInfo.RemoteAddress && ar[0].Split(':')[1] == e.UDPdataInfo.RemotePort.ToString())
             {
                 _receivedIDs.RemoveAt(i);
                 i--; max--;
             }
         }
     }
     //POUR MOI IL FAUT METTRE UN ELSE ICI
     this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_CANCELED, e.UDPdataInfo));
 }
Exemplo n.º 8
0
 private void _DeliveryHandler(UDPManagerEvent e)
 {
     if (e.UDPdataInfo.ChannelName == UDPManager._UDPMRCC && e.UDPdataInfo.Data.messageType.ToString() == "newConnection")
     {
         this._udpServer = new UDPPeer(e.UDPdataInfo.RemoteAddress, e.UDPdataInfo.RemotePort);
         this._udpServer.AddEventListener <Event>("ping", this._PingTimerHandler);
         this._udpServer.StartPingTimer();
         this._connecting = false;
         this._udpManager._UDPClientConnecting = null;
         this._connected = true;
         this.DispatchEvent(new UDPClientEvent(UDPClientEvent.Names.CONNECTED_TO_SERVER, this._udpServer));
     }
     else if (e.UDPdataInfo.ChannelName == UDPManager._UDPMRCP && e.UDPdataInfo.Data.messageType.ToString() == "ping")
     {
         this._udpServer.SetPing(e.UDPdataInfo.Ping);
         this._udpServer.StartPingTimer();
         this.DispatchEvent(new UDPClientEvent(UDPClientEvent.Names.SERVER_PONG, this._udpServer));
     }
     else
     {
         this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_DELIVERED, e.UDPdataInfo));
     }
 }
Exemplo n.º 9
0
        //
        //private methods
        //
        //UDPManagerEvents listeners
        private void _ReceivedDataHandler(UDPManagerEvent e)
        {
            UDPPeer peer;

            if (e.UDPdataInfo.ChannelName == UDPManager._UDPMRCC && e.UDPdataInfo.Data.messageType.ToString() == "newConnection")
            {   //implements connection feature
                peer = this._GetPeerByAddress(e.UDPdataInfo.RemoteAddress, e.UDPdataInfo.RemotePort);

                if (peer == null)
                {
                    peer = new UDPPeer(e.UDPdataInfo.RemoteAddress, e.UDPdataInfo.RemotePort);
                    this._peers.Add(peer);
                    this._udpManager._udpServerPeers.Add(peer);
                    this._udpManager._AddHiddenClientPingChannel(peer.ID);
                    peer.AddEventListener <Event>("ping", this._PingTimerHandler);
                    peer.StartPingTimer();
                    this.DispatchEvent(new UDPServerEvent(UDPServerEvent.Names.CLIENT_CONNECTED, peer));
                }
                else
                {
                    this.DispatchEvent(new UDPServerEvent(UDPServerEvent.Names.CLIENT_RECONNECTED, peer));
                }
            }
            else if (e.UDPdataInfo.ChannelName == UDPManager._UDPMRCP && e.UDPdataInfo.Data.messageType.ToString() == "ping")
            {           //implements ping feature
                        //do nothing
            }
            else
            {
                peer = this._peers.Where(a => a.Address == e.UDPdataInfo.RemoteAddress).Where(a => a.Port == e.UDPdataInfo.RemotePort).FirstOrDefault();
                if (peer != null)
                {
                    this.DispatchEvent(new UDPServerEvent(UDPServerEvent.Names.CLIENT_SENT_DATA, peer, e.UDPdataInfo));
                }
                this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_RECEIVED, e.UDPdataInfo));  //redispatch
            }
        }
Exemplo n.º 10
0
 private void _Listening(UDPManagerEvent e)
 {
     this.DispatchEvent(e);
 }
Exemplo n.º 11
0
 private void _RetryHandler(UDPManagerEvent e)
 {
     this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_RETRIED, e.UDPdataInfo));
 }
Exemplo n.º 12
0
 private void _RetryNotifForward(UDPManagerEvent e)
 { //console.log("RETRY ",e.udpDataInfo.channelName,e.udpDataInfo.data.messageType);
     this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_RETRIED, e.UDPdataInfo));
 }
Exemplo n.º 13
0
 private void _DeliveredNotifForward(UDPManagerEvent e)
 { //console.log("DATA DELIVERED ",e.udpDataInfo.channelName,e.udpDataInfo.data.messageType);
     this.DispatchEvent(new UDPManagerEvent(UDPManagerEvent.Names.DATA_DELIVERED, e.UDPdataInfo));
 }