Exemplo n.º 1
0
        public WebSocketHandler(string ip, ushort sendPort, ushort receivePort, int timeout, SocketIo parentSocket)
            : base(ip, sendPort, receivePort, timeout, parentSocket)
        {
            if (SendPort == 0)
            {
                SendPort = ReceivePort;
            }

            if (ReceivePort == 0)
            {
                ReceivePort = SendPort;
            }

            if (SendPort != ReceivePort)
            {
                throw new Exception("WebSockets must Send and Receive on the same port.");
            }

            _socket = WebSocketWrapper.Create($@"ws://{ip}:{ReceivePort}");
            _socket.Connect();
            Thread.Sleep(1000);
        }