Exemplo n.º 1
0
        public void Start(IScene scene)
        {
            Scene = scene;

            Scheduler = scene.Simian.GetAppModule<IScheduler>();
            if (Scheduler == null)
            {
                m_log.Error("Cannot start WebSockets without an IScheduler");
                throw new InvalidOperationException();
            }

            MessageEvents = new MessageEventDictionary(Scheduler);

            try
            {
                Server = new WebSocketServer(this);
                Server.Connected += ConnectedHandler;
                Server.Disconnected += DisconnectedHandler;
                Server.DataReceived += DataReceivedHandler;

                Server.Start(12000, "http://localhost:12000", "ws://localhost:12000/");
            }
            catch (Exception ex)
            {
                m_log.Error("WebSocket server failed to start: " + ex.Message);
            }
        }
Exemplo n.º 2
0
 public void Stop()
 {
     if (Server != null)
     {
         Server.Stop();
         Server = null;
     }
 }