Example #1
0
        /// <summary></summary>
        public void EnsureServer()
        {
            if (Server == null)
            {
                if (ProtocolType == NetType.Tcp)
                {
                    var server = new TcpServer();
                    Server = server;
                    //server.ReuseAddress = true;
                    server.NewSession += server_Accepted;
                }
                else
                {
                    var server = new UdpServer();
                    //Server = server;
                    //server.ReuseAddress = true;
                    server.Received += server_Received;
                    //server.Bind();
                    server.ReceiveAsync();
                }

                Server.Start();

                WriteLog("监听:{0}", Server);
            }
        }
Example #2
0
        /// <summary>开始</summary>
        public void Start()
        {
            if (Client == null)
            {
                Client           = new UdpServer();
                Client.Received += Client_Received;
                Client.Open();

                _Timer = new TimerX(s =>
                {
                    try
                    {
                        SendDiscover();
                    }
                    catch (Exception ex) { WriteLog(ex.ToString()); }
                }, null, 0, 1000);
            }

            //var rnd = new Random();
            TransID = Rand.Next();
            if (_Mac == null || _Mac.Length == 0)
            {
                _Mac = NetHelper.GetMacs().FirstOrDefault();
            }
            if (_Mac == null || _Mac.Length == 0)
            {
                _Mac = Rand.NextBytes(6);
            }
        }
Example #3
0
        /// <summary>开始</summary>
        public void Start()
        {
            if (Client == null)
            {
                Client           = new UdpServer();
                Client.Received += Client_Received;
                Client.Open();

                _Timer = new TimerX(s =>
                {
                    try
                    {
                        SendDiscover();
                    }
                    catch (Exception ex) { WriteLog(ex.ToString()); }
                }, null, 0, 1000);
            }

            //var rnd = new Random();
            TransID = Rand.Next();
            if (_Mac == null || _Mac.Length == 0)
            {
                _Mac = HardInfo.Current.Macs.Replace(":", null).ToHex();
            }
            if (_Mac == null || _Mac.Length == 0)
            {
                _Mac = Rand.NextBytes(6);
            }
        }
        public void Start()
        {
            // Install ScpVBus every time application is launched
            // Must be installed synchronously
            // Uninstall it on exit (see region below)
            // scpInstaller.Install();

            Status = "Checking for updates";
            AppCastUpdater.Start();

            Status = "Starting network services";
            // Get number of expected mobile device inputs from Default
            UdpServer.Start(Properties.Settings.Default.LastPort);
            int port = UdpServer.Port;

            Properties.Settings.Default.LastPort = port;
            Properties.Settings.Default.Save();

            // publish network service for primary device
            DnsServer.Publish(port, "Primary");

            Status = "Creating virtual devices";

            Properties.Settings.Default.FirstInstall = false;
            Properties.Settings.Default.Save();
            try
            {
                ForceFirewallWindow();
            }
            catch (Exception e)
            {
                log.Error("Unable to open temp TCP socket because: " + e.Message);
                log.Info("Windows Firewall should prompt on the next startup.");
            }
        }
Example #5
0
        public void enviarStreaming(int numberDevice, string ipReceptor, string ipEmisor, int puerto)
        {
            try
            {
                numeroDispositivo = numberDevice;
                servidorUdp = new UdpServer();
                servidorUdp.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(ipEmisor), (int)puerto) };
                servidorUdp.Start();

                puntoDestino = new IPEndPoint(IPAddress.Parse(ipReceptor), (int)puerto);

                waveIn = new WaveIn(WaveIn.Devices[numberDevice], 8000, 16, 1, 400);
                waveIn.BufferFull += new BufferFullHandler(waveIn_BufferFull);
                waveIn.Start();
            }
            catch (Exception ex)
            {
                logger.WriteToEventLog("ERROR: " + ex.Message +
                                        Environment.NewLine +
                                        "STACK TRACE: " + ex.StackTrace,
                                        "Servicio de envio de streaming [enviarStreaming]",
                                        EventLogEntryType.Error,
                                        "LogSucursalAudio");
                logger.WriteToErrorLog("ERROR: " + ex.Message,
                                        ex.StackTrace,
                                        "Streaming.cs");

                Console.WriteLine("Error [enviarStreaming]: " + ex.Message);
                Console.WriteLine("StackTrace [enviarStreaming]: " + ex.StackTrace);
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.Title = "JAWE.Game";

            //Console.WriteLine("Initialized MessageProcessor with {0} messages.", MessageProcessorOld.MessagesCount);
            Console.WriteLine("Initialized MessageTable with {0} handlers.", GameClient.MessageTable.HandlerCount);

#if !DEBUG
            HearthBeat.Initialize();
#endif

            var server = new GameServer();

            var peerServer = new UdpServer(5350, GameClient.WrEncoder);
            var natServer  = new UdpServer(5351, null);

            server.Activate();
            peerServer.Activate();
            natServer.Activate();

            Console.WriteLine("Hello World!");

            // TODO Keep main thread active until the server is fully shutdown.
            while (true)
            {
                Console.ReadKey(true);
            }
        }
Example #7
0
        static void Test5()
        {
            if (_udpServer != null)
            {
                return;
            }

            _udpServer      = new UdpServer();
            _udpServer.Port = 888;
            //_udpServer.Received += _udpServer_Received;
            _udpServer.SessionTimeout = 5000;
            _udpServer.Open();

            var session = _udpServer.CreateSession(new IPEndPoint(IPAddress.Any, 0));

            for (int i = 0; i < 5; i++)
            {
                var buf = session.Receive();
                Console.WriteLine(buf.ToHex());
                session.Send("Hello");
            }

            //Console.ReadKey();
            _udpServer.Dispose();
            _udpServer = null;
        }
Example #8
0
        public async Task Update()
        {
            var result = await UdpServer.ReceiveAsync();

            var parsed   = Packet.Parse(result.Buffer);
            var endPoint = result.RemoteEndPoint;

//            Console.WriteLine($"{parsed}");

            switch (parsed.Type)
            {
            case PacketType.UnconnectedPing: { await SendRaw(endPoint, UnconnectedPongPacket.FromPing(parsed.Get <UnconnectedPingPacket>(), Guid, "MCPE.AlphaServer")); break; }

            case PacketType.OpenConnectionRequest1: { await SendRaw(endPoint, OpenConnectionReplyPacket.FromRequest(parsed.Get <OpenConnectionRequestPacket>(), Guid, endPoint)); break; }

            case PacketType.OpenConnectionRequest2: {
                var packet = parsed.Get <OpenConnectionRequestPacket>();
                var Client = new UdpConnection(endPoint);
                Clients.Add(endPoint, Client);
                await SendRaw(endPoint, OpenConnectionReplyPacket.FromRequest(packet, Guid, endPoint));

                break;
            }

            case PacketType.RakNetPacket: { await HandleRakNetPacket(parsed.Get <RakNetPacket>(), endPoint); break; }

            default:
                break;
            }
        }
Example #9
0
    private static void Main()
    {
        //NetBase.DebugInfoReceived += (i) => Console.WriteLine(i);

        UdpServer sv = new UdpServer();

        sv.AddNetEventsFromAssembly(Assembly.GetExecutingAssembly());

        if (!sv.StartServer(7235))
        {
            throw new Exception("Server failed to start!");
        }

        for (ushort i = 0; i < 1; ++i)
        {
            UdpClient cl = new UdpClient();
#if DEBUG
            cl.DropChance = 0.01;
#endif

            cl.AddNetEventsFromAssembly(Assembly.GetExecutingAssembly());
            cl.ClientDisconnected += (c) => Console.WriteLine("Client Disconnected!");
            if (!cl.VerifyAndListen(7235))
            {
                throw new Exception("Client failed to start!");
            }

            cl.SendF(0, PacketFlags.Reliable, 0, i);
        }

        while (Console.ReadKey().Key != ConsoleKey.Escape)
        {
        }
        sv.Close();
    }
Example #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello TinySocketServer!");

            #region 继承UDP服务器的实现

            var udp_server = new UdpServer();
            //UDP本地侦听端口
            var localPoint = new IPEndPoint(IPAddress.Any, 9090);
            //启动UDP服务器
            udp_server.Start(localPoint);

            #endregion

            #region 继承Tcp服务器的实现

            var tcp_server = new TcpServer();
            //启用TCP服务器,侦听地下和端口值 和上面的UDP一样
            tcp_server.Start(localPoint);
            #endregion
            while (true)
            {
                if (Console.ReadLine().ToUpper() == "EXIT")
                {
                    break;
                }
            }
        }
Example #11
0
 public Server()
 {
     worldPersistence = new WorldPersistence();
     world            = worldPersistence.Load();
     packetHandler    = new PacketHandler(world);
     udpServer        = new UdpServer(packetHandler, world.PlayerManager, world.EntitySimulation);
 }
Example #12
0
        public void StartInfoThread()
        {
            string hostName = NetworkUtils.getHostName();
            // Get the IP
            string myIP = NetworkUtils.getIpAddress();

            Console.WriteLine("my ip: {0}", myIP);
            var netThread = UdpServer.GetInstance();

            rigBusDesc         = OmniRigInfo.Instance;
            rigBusDesc.Command = "update";

            rigBusDesc.UdpPort      = netThread.listenUdpPort;
            rigBusDesc.TcpPort      = netThread.listenTcpPort;
            rigBusDesc.MinVersion   = 1;
            rigBusDesc.MaxVersion   = 1;
            rigBusDesc.Host         = hostName;
            rigBusDesc.Ip           = myIP;
            rigBusDesc.SendSyncInfo = true;
            rigBusDesc.RigType      = "Unknown";
            rigBusDesc.Name         = "OmniRig RigBus";
            rigBusDesc.Description  = "OmniRig RigBus";
            infoThread = new Thread(SendRigBusInfo);
            infoThread.Start();
        }
Example #13
0
        public void startRecordServer(int codec, string m_pLoacalIP, int m_pLocalPort, string m_pRemoteIP, int m_pRemotePort, int m_pInDevicesselected)
        {
            try
            {
                if (m_pUdpServer != null)
                {
                    m_pUdpServer.Dispose();
                    m_pUdpServer = null;
                }

                if (m_pWaveIn != null)
                {
                    m_pWaveIn.Dispose();
                    m_pWaveIn = null;
                }


                m_Codec               = codec;
                m_pUdpServer          = new UdpServer();
                m_pUdpServer.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(m_pLoacalIP), m_pLocalPort) };

                m_pUdpServer.Start();


                m_pTargetEP = new IPEndPoint(IPAddress.Parse(m_pRemoteIP), m_pRemotePort);

                m_pWaveIn             = new WaveIn(WaveIn.Devices[m_pInDevicesselected], 11025, 16, 1, 400);
                m_pWaveIn.BufferFull += new BufferFullHandler(m_pWaveIn_BufferFull);
                m_pWaveIn.Start();
            }
            catch (Exception ex)
            {
            }
        }
Example #14
0
        public RbrServer(string pFilePath)
        {
            rbrProcessFilePath = pFilePath;
            currentNode        = new CurrentNode();

            TimokLogger.Instance.LogRbr(LogSeverity.Status, "===============================================================================");
            TimokLogger.Instance.LogRbr(LogSeverity.Status, RBR_SERVER_CTOR_LABEL, string.Format("Version: {0}", Assembly.GetExecutingAssembly().GetName().Version));
            TimokLogger.Instance.LogRbr(LogSeverity.Status, RBR_SERVER_CTOR_LABEL, string.Format("LogSeverity Level: {0}", TimokLogger.Instance.LogSeverity));

            //-- add and set email logger
            var _folder   = Configuration.Instance.Folders.EmailFolder;
            var _server   = string.Format("{0}@{1}", Configuration.Instance.Main.HostName, Configuration.Instance.Main.HostIP);
            var _s        = Configuration.Instance.Email.SupportEmailServer;
            var _from     = Configuration.Instance.Email.SupportFrom;
            var _password = Configuration.Instance.Email.SupportEmailPassword;
            var _to       = Configuration.Instance.Email.SupportTo;

            //TODO: srdjan
            //TimokLogger.Instance.AddEmailLogger(_folder, _server, _s, _from, _password, _to, Email.SetForSending);

            try {
                houskeeper     = new Houskeeper();
                callStatistics = new CallStatistics();

                var _udpCommandFactory = new UdpCommandFactory(callStatistics);
                udpServer = new UdpServer(Configuration.Instance.Main.UdpServerIp, Configuration.Instance.Main.UdpServerRbrPort, _udpCommandFactory, TimokLogger.Instance.LogRbr);

                TimokLogger.Instance.LogRbr(LogSeverity.Status, "===============================================================================");
            }
            catch (Exception _ex) {
                TimokLogger.Instance.LogRbr(LogSeverity.Critical, RBR_SERVER_CTOR_LABEL, string.Format("Exception:\r\n{0}", _ex));
                throw;
            }
        }
Example #15
0
        /// <summary>开始</summary>
        public void Start()
        {
            if (Client == null)
            {
                Client = new UdpServer();
                Client.Received += Client_Received;
                Client.Open();

                _Timer = new TimerX(s =>
                {
                    try
                    {
                        SendDiscover();
                    }
                    catch (Exception ex) { WriteLog(ex.ToString()); }
                }, null, 0, 1000);
            }

            //var rnd = new Random();
            TransID = Rand.Next();
            if (_Mac == null || _Mac.Length == 0)
                _Mac = HardInfo.Current.Macs.Replace(":", null).ToHex();
            if (_Mac == null || _Mac.Length == 0)
                _Mac = Rand.NextBytes(6);
        }
Example #16
0
        /// <summary></summary>
        public void EnsureServer()
        {
            if (Server == null)
            {
                if (ProtocolType == NetType.Tcp)
                {
                    var server = new TcpServer();
                    Server = server;
                    //server.ReuseAddress = true;
                    server.NewSession += server_Accepted;
                }
                else
                {
                    var server = new UdpServer();
                    //Server = server;
                    //server.ReuseAddress = true;
                    server.Received += server_Received;
                    //server.Bind();
                    server.Open();
                }

                Server.Start();

                WriteLog("监听:{0}", Server);
            }
        }
Example #17
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (UDPServerThread != null)
             {
                 try
                 {
                     _RequestStop = true;
                     Delay(100);
                     UDPServerThread.Abort();
                     UDPServerThread = null;
                 }
                 catch (Exception e1) { }
             }
             if (UdpServer != null)
             {
                 UdpServer.Close();
             }
         }
         disposed = true;
     }
 }
Example #18
0
        public void StartInfoThread()
        {
            string hostName = Dns.GetHostName(); // Retrive the Name of HOST
            string myIP     = Dns.GetHostEntry(hostName).AddressList[0].ToString();

            var udpServer = UdpServer.GetInstance();

            rigBusDesc              = VirtualRigInfo.Instance;
            rigBusDesc.Command      = "update";
            rigBusDesc.Id           = Id;
            rigBusDesc.UdpPort      = udpServer.listenUdpPort;
            rigBusDesc.TcpPort      = udpServer.listenTcpPort;
            rigBusDesc.MinVersion   = 1;
            rigBusDesc.MaxVersion   = 1;
            rigBusDesc.Host         = hostName;
            rigBusDesc.Description  = "Kenwood Virtual RigBus";
            rigBusDesc.Ip           = myIP;
            rigBusDesc.SendSyncInfo = true;
            rigBusDesc.RigType      = Constants.VirtualRigType;
            rigBusDesc.Name         = Constants.VirtualRigName;
            rigBusDesc.DocType      = DocTypes.RigBusInfo;;

            infoThread = new Thread(SendRigBusInfo);
            infoThread.Start();

            var dirClient = DirectoryClient.Instance;

            dirClient.StartThread();
        }
Example #19
0
        /// <summary>根据本地网络标识创建客户端</summary>
        /// <param name="local"></param>
        /// <returns></returns>
        public static ISocketClient CreateClient(this NetUri local)
        {
            if (local == null)
            {
                throw new ArgumentNullException("local");
            }

            switch (local.Type)
            {
            case NetType.Tcp:
                var tcp = new TcpSession {
                    Local = local
                };
                return(tcp);

            case NetType.Udp:
                var udp = new UdpServer {
                    Local = local
                };
                return(udp);

            default:
                throw new NotSupportedException("不支持{0}协议".F(local.Type));
            }
        }
Example #20
0
 public void Stop()
 {
     IsRuning = false;
     UdpServer.Close();
     UdpServer.Dispose();
     UdpServer = null;
 }
Example #21
0
        void udp_OnReceivedData(object sender, UdpService.ReceivedDataEventArgs e)
        {
            try
            {
                UdpServer udp = sender as UdpServer;
                //添加入连接列表
                //UdpBussiness.AddSocket(udp, e.ClientSocket);

                //写入接收数据队列
                UdpBussiness.WriteUrdQ(udp, e.ClientSocket, e.RevData);

                //写入透明传输的数据报列表
                ServiceBussiness.WriteQDM(e.RevData);
                //写入日志
                LogInfoToTxt(ServiceEnum.NFOINDEX.UDP, e.ClientSocket.Address + ":" + e.ClientSocket.Port, e.RevData);

                //写入待发送至界面的数据处理列表(透明传输代替)
                //ServiceBussiness.WriteQRDM(udp.ServiceID, e.RevData);

                //解析数据包
                UdpBussiness.ResolvePacket(udp);
            }
            catch (Exception ex)
            {
                log.Error(DateTime.Now + "接收处理操作异常" + ex.ToString());
            }
        }
Example #22
0
        /// <summary>根据远程网络标识创建客户端</summary>
        /// <param name="remote"></param>
        /// <returns></returns>
        public static ISocketClient CreateRemote(this NetUri remote)
        {
            if (remote == null)
            {
                throw new ArgumentNullException("remote");
            }

            switch (remote.Type)
            {
            case NetType.Tcp:
                var tcp = new TcpSession {
                    Remote = remote
                };
                return(tcp);

            case NetType.Udp:
                var udp = new UdpServer {
                    Remote = remote
                };
                return(udp);

            default:
                throw new NotSupportedException("不支持{0}协议".F(remote.Type));
            }
        }
    static void Main(string[] args)
    {
        WorldData worldData = new WorldData();

        InstantiateWeapons(worldData);
        IModelManager modelManager  = new ModelManager(worldData);
        ISerializer   serializer    = new JsonNetSerializer();
        UdpServerInfo udpServerInfo = new UdpServerInfo
        {
            Port               = 3000,
            ChannelId          = 0,
            MaxClients         = 100,
            PeerTimeOutLimit   = 32,
            PeerTimeOutMinimum = 1000,
            PeerTimeOutMaximum = 4000
        };

        using IServer server = new UdpServer(udpServerInfo);
        NetworkManager networkManager = new NetworkManager(server, serializer, modelManager, worldData, 500);

        networkManager.Start();
        Console.WriteLine("Press 'q' to stop server");
        while (Console.ReadKey().Key != ConsoleKey.Q)
        {
        }

        networkManager.Stop();
    }
Example #24
0
 /// <summary>
 /// This method is called when this form is closed.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">Event data.</param>
 private void wfrm_Main_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (m_pUdpServer != null)
     {
         m_pUdpServer.Dispose();
         m_pUdpServer = null;
     }
     if (m_pWaveIn != null)
     {
         m_pWaveIn.Dispose();
         m_pWaveIn = null;
     }
     if (m_pWaveOut != null)
     {
         m_pWaveOut.Dispose();
         m_pWaveOut = null;
     }
     if (m_pRecordStream != null)
     {
         m_pRecordStream.Dispose();
         m_pRecordStream = null;
     }
     if (m_pTimer != null)
     {
         m_pTimer.Dispose();
         m_pTimer = null;
     }
 }
        /// <summary>
        /// Finds the parts.
        /// </summary>
        protected override void FindParts()
        {
            base.FindParts();

            if (IsFirstRun)
            {
                RegisterServerWithAdministratorAccess();
            }

            Parallel.Invoke(

                () =>
            {
                HttpServer.Init(GetExports <IRestfulService>(false));

                ServerManager.AddWebSocketListeners(GetExports <IWebSocketListener>(false));
                ServerManager.Start();
            },

                () => LibraryManager.AddParts(GetExports <IResolverIgnoreRule>(), GetExports <IVirtualFolderCreator>(), GetExports <IItemResolver>(), GetExports <IIntroProvider>(), GetExports <IBaseItemComparer>()),

                () => ProviderManager.AddMetadataProviders(GetExports <BaseMetadataProvider>().OrderBy(e => e.Priority).ToArray())
                );

            UdpServer = new UdpServer(Logger, NetworkManager, ServerConfigurationManager);

            try
            {
                UdpServer.Start(UdpServerPort);
            }
            catch (SocketException ex)
            {
                Logger.ErrorException("Failed to start UDP Server", ex);
            }
        }
Example #26
0
        static void Test6()
        {
            // UDP没有客户端服务器之分。推荐使用NetUri指定服务器地址
            var udp = new UdpServer();

            udp.Remote    = new NetUri("udp://smart.peacemoon.cn:7");
            udp.Received += (s, e) =>
            {
                XTrace.WriteLine("收到:{0}", e.ToStr());
            };
            udp.Open();
            udp.Send("新生命团队");
            udp.Send("学无先后达者为师!");

            // Tcp客户端会话。改用传统方式指定服务器地址
            var tcp = new TcpSession();

            tcp.Remote.Host = "smart.peacemoon.cn";
            tcp.Remote.Port = 13;
            tcp.Open();
            var str = tcp.ReceiveString();

            XTrace.WriteLine(str);

            // 产品级客户端用法。直接根据NetUri创建相应客户端
            var client = new NetUri("tcp://smart.peacemoon.cn:17").CreateRemote();

            client.Received += (s, e) =>
            {
                XTrace.WriteLine("收到:{0}", e.ToStr());
            };
            client.Open();

            Thread.Sleep(1000);
        }
Example #27
0
        private void m_pToggleRun_Click(object sender, EventArgs e)
        {
            if (m_IsRunning)
            {
                m_IsRunning = false;


                m_pUdpServer.Dispose();
                m_pUdpServer = null;

                m_pWaveOut.Dispose();
                m_pWaveOut = null;

                if (m_pRecordStream != null)
                {
                    m_pRecordStream.Dispose();
                    m_pRecordStream = null;
                }

                m_pTimer.Dispose();
                m_pTimer = null;


                m_pToggleRun.Text = "Bắt đầu lắng nghe";
            }
            else
            {
                if (m_pOutDevices.SelectedIndex == -1)
                {
                    MessageBox.Show(this, "Bạn hãy chọn thiết bị đầu ra !", "Lỗi:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (m_pRecord.Checked && m_pRecordFile.Text == "")
                {
                    MessageBox.Show(this, "Bạn hãy chọn tập tin đầu ra !", "Lối:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (m_pRecord.Checked)
                {
                    m_pRecordStream = File.Create(m_pRecordFile.Text);
                }

                m_IsRunning       = true;
                m_pToggleRun.Text = "Dừng lắng nghe";
                m_Codec           = m_pCodec.SelectedIndex;

                m_pWaveOut = new WaveOut(WaveOut.Devices[m_pOutDevices.SelectedIndex], 11025, 16, 1);

                m_pUdpServer                 = new UdpServer();
                m_pUdpServer.Bindings        = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(m_pLoacalIP.Text), (int)m_pLocalPort.Value) };
                m_pUdpServer.PacketReceived += new PacketReceivedHandler(m_pUdpServer_PacketReceived);
                m_pUdpServer.Start();



                m_pTimer.Enabled = true;
            }
        }
Example #28
0
 public void recibirStreaming(int numberDevice, string ipEmisor, int puerto)
 {
     waveOut = new WaveOut(WaveOut.Devices[numberDevice], 8000, 16, 1);
     servidorUdp = new UdpServer();
     servidorUdp.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(ipEmisor), (int)puerto) };
     servidorUdp.PacketReceived += new PacketReceivedHandler(recibirPaquetes_ServidorUdp);
     servidorUdp.Start();
 }
Example #29
0
        private void btnUdpServerTest_Click(object sender, EventArgs e)
        {
            _server = new UdpServer(5555, 4445, 10);
            _server.OnReceiveData += new EventHandler <SocketAsyncEventArgs>(testServer_OnReceiveData);
            //_server.OnSendData += new EventHandler<SocketAsyncEventArgs>( testServer_OnSendData );

            _server.Start();
        }
Example #30
0
        /// <summary>
        /// On Socket Initialized
        /// </summary>
        /// <param name="localPort"></param>
        private void OnSocketInitialized(ushort localPort)
        {
            UdpServer = HPSocketExtension.CreateServer <UdpServer>(localPort, ClientDataHandler);
            TcpServer = HPSocketExtension.CreateServer <TcpServer>(localPort, ClientDataHandler);

            DataAnalyse = new SocketDataAnalyse <string>();
            DataAnalyse.AddChannel("socket.client", 128);
        }
Example #31
0
 public bool Send(byte[] data)
 {
     try
     {
         UdpServer.Send(data, data.Length, Ep.ToIpEndPoint());
     }
     catch (Exception ex) { log.Error(ex); return(false); }
     return(true);
 }
Example #32
0
 // Use this for initialization
 void Start()
 {
     controller   = new Controller();
     leftFingers  = new Finger[5];
     rightFingers = new Finger[5];
     server       = new UdpServer();
     server.init(5432, 1234);
     StartCoroutine(loop());
 }
 private void Awake()
 {
     tcpClient           = new TcpClient(server, Utils.SERVER_TCP_PORT);
     udpClient           = new UdpClient();
     udpCounter          = 0;
     udpServer           = new UdpServer(UdpReceived);
     otherClientsData    = new Dictionary <int, ClientTransform>();
     otherClientsObjects = new Dictionary <int, GameObject>();
 }
Example #34
0
        public async Task Send(UdpConnection Client, params RakPacket[] packets)
        {
            var rakPacket = RakNetPacket.Create(Client.Sequence);

            Client.Sequence = Client.Sequence.Add(1);
            rakPacket.Enclosing.AddRange(packets);
            var data = rakPacket.Serialize();
            await UdpServer.SendAsync(data, data.Length, Client.EndPoint);
        }
        public void JoinConference(int MicIndex)
        {
            if (!InConference)
            {
                audioWaveOut = new WaveOut(WaveOut.Devices[0], 8000, 16, 1);
                audioServer = new UdpServer();
                audioServer.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(Main.User.MyIPAddress), audioPort) };
                audioServer.PacketReceived += new PacketReceivedHandler(AudioServer_PacketReceived);
                audioServer.Start();

                audioWaveIn = new WaveIn(WaveIn.Devices[MicIndex], 8000, 16, 1, 400);
                audioWaveIn.BufferFull += new BufferFullHandler(audioWaveIn_BufferFull);
                audioWaveIn.Start();
                InConference = true;
            }
        }
        private void btn_StartAudio_Click(object sender, EventArgs e)
        {
            if (audioIsRunning)
            {
                audioIsRunning = false;
                audioServer.Dispose();
                audioServer = null;
                audioWaveOut.Dispose();
                audioWaveOut = null;

                audioWaveIn.Dispose();
                audioWaveIn = null;
                btn_StartAudio.BackColor = Color.Green;
                ddl_AudioDevices.Enabled = true;
            }
            else
            {
                audioIsRunning = true;
                audioWaveOut = new WaveOut(WaveOut.Devices[0], 8000, 16, 1);
                audioServer = new UdpServer();
                audioServer.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(GetMyIP()), audioPort) };
                audioServer.PacketReceived += new PacketReceivedHandler(AudioServer_PacketReceived);
                audioServer.Start();

                audioWaveIn = new WaveIn(WaveIn.Devices[ddl_AudioDevices.SelectedIndex], 8000, 16, 1, 400);
                audioWaveIn.BufferFull += new BufferFullHandler(audioWaveIn_BufferFull);
                audioWaveIn.Start();
                btn_StartAudio.BackColor = Color.Red;
                ddl_AudioDevices.Enabled = false;
            }
        }
Example #37
0
 private SoundUdpServer()
 {
     udpServer = new UdpServer();
 }
Example #38
0
 static void Main(string[] args)
 {
     UdpServer hat = new UdpServer();
     hat.Run();
     Console.ReadKey();
 }
        protected override void Given()
        {
            _packet1 = new FakeUdpPacket("1", DefaultRemoteEp);
            _packet2 = new FakeUdpPacket("1", DefaultRemoteEp);

            var fakePackets = new Stack<FakeUdpPacket>();
            fakePackets.Push(_packet1);
            fakePackets.Push(_packet2);
            _fakeSocketImpl = new FakeSocketImpl(fakePackets);

            _messageprocessor = new Mock<IUdpMessageProcessor>();

            _sipStack = new SipStack();
            _udpServer = new UdpServer(_sipStack, _listeningPoint, _fakeSocketImpl, _messageprocessor.Object);
        }