Beispiel #1
0
        /// <summary>
        /// Listens (and creates a server if needed) to remote connections.
        /// </summary>
        public void Listen()
        {
            if (WS != null)
            {
                throw new Exception("Cannot both be a server and a client." +
                                    " Please use Connect if you are connecting to a server or Listen to create a server.");
            }

            if (WSServer == null)
            {
                MakeServer();
            }

            WSServer.Start();

            DataSocket.Initialize();
        }
Beispiel #2
0
        /// <summary>
        /// Connects to the remote server as a client.
        /// </summary>
        /// <param name="address"></param>
        public void Connect(bool async = false)
        {
            if (WSServer != null)
            {
                throw new Exception("Cannot both be a server and a client." +
                                    " Please use Connect if you are connecting to a server or Listen to create a server.");
            }

            MakeClient();

            if (async)
            {
                WS.ConnectAsync();
            }
            else
            {
                WS.Connect();
            }

            DataSocket.Initialize();
        }