Exemplo n.º 1
0
        /// <summary>
        /// Creates the server. Will override old servers.
        /// </summary>
        /// <param name="address">If != null then use this addres (changes the address of the websocket pipe)</param>
        public void MakeServer(Uri address = null)
        {
            if (address == null)
            {
                address = Address;
            }

            // Stop the old if any.
            if (WSServer != null && WSServer.IsListening)
            {
                WSServer.Stop();
            }

            string serverURL = address.Scheme + "://" + address.Host + ":" + Address.Port;

            WSServer = new WebSocketSharp.Server.WebSocketServer(serverURL);

            // Creates a server.
            WSServer.AddWebSocketService <WebsocketConnection>(
                address.AbsolutePath, () => new WebsocketConnection(this));

            WSServer.Log.Output = (d, s) => WebsocketLogMessage(null, d.ToString());

            if (m_WaitTimeout == null)
            {
                m_WaitTimeout = WSServer.WaitTime;
            }
            else
            {
                WSServer.WaitTime = WaitTimeout;
            }
        }
Exemplo n.º 2
0
    void InitNetwork()
    {
        WSServerState.Reset();

        if (DebugStandalone)
        {
            WSServer.Stop();
            WSServerState.Reset();
            WSClient.Disconnect();
            WSClientState.Reset();
            WSServer.StartFake();
            WSClient.ConnectFake();
        }
        else if (IsClient)
        {
            WSServer.Stop();
            WSServerState.Reset();
            WSClient.Connect();
        }
        else
        {
            WSClient.Disconnect();
            WSClientState.Reset();
            if (!WSServer.IsRunning)
            {
                WSServer.Start();
            }
        }
    }
Exemplo n.º 3
0
 public void OnDestroy()
 {
     WebRTC.Finalize();
     Audio.Stop();
     ws = null;
     wss.Stop();
 }
Exemplo n.º 4
0
 public void Stop()
 {
     if (_alchemy != null)
     {
         _alchemy.Stop();
         _alchemy = null;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Stops listening to remote connections.
        /// </summary>
        public void StopListening()
        {
            if (WS != null)
            {
                throw new Exception("Cannot both be a server and a client." +
                                    " Please use Disconnect if you are diconnecting from a server or StopListening to stop the server.");
            }

            if (WSServer == null)
            {
                return;
            }

            if (WSServer.IsListening)
            {
                WSServer.Stop();
            }

            DataSocket.Close();
        }
Exemplo n.º 6
0
        public void Dispose()
        {
            if (WS != null && WS.IsAlive)
            {
                WS.Close();
            }
            if (WSServer != null && WSServer.IsListening)
            {
                WSServer.Stop();
            }

            if (DataSocket != null)
            {
                DataSocket.Close();
            }

            WS         = null;
            WSServer   = null;
            DataSocket = null;
            Serializer = null;
        }
Exemplo n.º 7
0
 void OnApplicationQuit()
 {
     WSServer.Stop();
     WSClient.Disconnect();
 }
Exemplo n.º 8
0
 private void StopServer()
 {
     httpServer.Stop();
     wsServer.Stop();
 }
Exemplo n.º 9
0
 public void Stop()
 {
     _wsServer.Stop();
 }
Exemplo n.º 10
0
 public void Stop()
 {
     httpService.Stop();
     wsService.Stop();
 }