Esempio n. 1
0
        public override void OnOpen()
        {
            //��UDP�˿ڣ��ȴ����ݴ���
            this.updServer = UDPServer.getUDPServer(Program.GPS_UDP_Port);
            updServer.evtReceived += new OnReceiveString(updServer_evtReceived);
            updServer.startUDPListening();

            GPS = new NmeaInterpreter();
            GPS.PositionReceived += new NmeaInterpreter.PositionReceivedEventHandler(GPS_PositionReceived);
        }
Esempio n. 2
0
 public static UDPServer getUDPServer(int port)
 {
     UDPServer server = null;
     if (!UDPServerList.ContainsKey(port))
     {
         server = new UDPServer(port);
         UDPServer.UDPServerList.Add(port, server);
     }
     else
     {
         server = UDPServer.UDPServerList[port];
     }
     return server;
 }
Esempio n. 3
0
        public void setDevice(ModuleCommand.command cmd, Action<ModuleCommand.command> callback)
        {
            myCallBack = callback;
            myCommand = cmd;

            rfid_helper = new TDJ_RFIDHelper();

            //打开UDP端口,等待数据传入
            this.updServer = UDPServer.getUDPServer(Program.UHF_UDP_Port);
            updServer.evtReceived += new OnReceiveString(updServer_evtReceived);
            updServer.startUDPListening();

            Debug.WriteLine(string.Format("*****  UHFDevice onListening... "));
        }
Esempio n. 4
0
        public void setDevice(ModuleCommand.command cmd, Action<ModuleCommand.command> callback)
        {
            myCallBack = callback;
            myCommand = cmd;

            //打开UDP端口,等待数据传入
            this.updServer = UDPServer.getUDPServer(Program.GPS_UDP_Port);
            updServer.evtReceived += new OnReceiveString(updServer_evtReceived);
            updServer.startUDPListening();

            GPS = new NmeaInterpreter();
            GPS.PositionReceived += new NmeaInterpreter.PositionReceivedEventHandler(GPS_PositionReceived);

            Debug.WriteLine(string.Format("*****  GPSService onListening... "));
        }
Esempio n. 5
0
        public UHFService(WebSocketServiceManager _manager, IWebSocketConnection socket)
        {
            services.register_service("uhf", this);
            this.ID = socket.ConnectionInfo.Id.ToString();
            this._manager = _manager;
            this._websocket = socket;
            this._context = socket.ConnectionInfo;

            rfid_helper = new TDJ_RFIDHelper();

            //��UDP�˿ڣ��ȴ����ݴ���
            this.updServer = UDPServer.getUDPServer(Program.UHF_UDP_Port);
            updServer.evtReceived += new OnReceiveString(updServer_evtReceived);
            updServer.startUDPListening();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            GetIpList();

            GetTcpPort();

            UDPServer udpServer = new UDPServer(tcpPort);
            TCPServer tcpServer = new TCPServer(tcpPort, localIpListForTcp);

            //odpowiedz od klienta z komunikatem i nr portu
            udpServer.StartListening();

            //Tworzenie socketow i watkow dla nasluchu TCP
            tcpServer.StartTCPListening();

            udpServer.ListenThrad.Join();
        }
        /// <summary>
        /// The Validation.
        /// </summary>
        /// <param name="connectionType">The connectionType<see cref="string"/>.</param>
        /// <param name="port">The port<see cref="string"/>.</param>
        /// <returns>The <see cref="IWorker"/>.</returns>
        public IWorker Validation(string connectionType, string port)
        {
            int  Port;
            bool isValidPort = Int32.TryParse(port, out Port);

            if (connectionType == "Udp")
            {
                var udpServer = new UDPServer();

                if (isValidPort)
                {
                    udpServer.Port = Port;
                }
                else
                {
                    udpServer.Port = 80;
                }

                return(udpServer);
            }
            else if (connectionType == "Tcp")
            {
                var tcpServer = new TCPServer();

                if (isValidPort)
                {
                    tcpServer.Port = Port;
                }
                else
                {
                    tcpServer.Port = 80;
                }

                return(tcpServer);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 8
0
 /// <summary>Sends data to the client via UDP.</summary>
 /// <param name="_packet">The packet to send.</param>
 public void SendData(Packet _packet)
 {
     UDPServer.SendUDPData(endPoint, _packet);
 }
Esempio n. 9
0
 private void RegisterEvent(OutgoingGameEvent gameEvent, int receiverPlayerID)
 {
     byte[] message = gameEvent.GetSerialized();
     UDPServer.GetInstance().SendMessageToPlayer(message, message.Length, receiverPlayerID);
 }
Esempio n. 10
0
 private void RegisterEvent(OutgoingGameEvent gameEvent)
 {
     byte[] message = gameEvent.GetSerialized();
     UDPServer.GetInstance().SendMessageToAll(message, message.Length);
 }