Exemple #1
0
 public String2 this[String2 key] {
     get
     {
         key = key.ToUpper();
         if (option.ContainsKey(key))
         {
             return(option[key]);
         }
         return(null);
     }
 }
Exemple #2
0
        public void SocketServer()
        {
            IServer server = ServerFactory.CreateServer(80, 500);

            server.Acception += (client) =>
            {
                try
                {
                    HandShake header = client.Receive();
                    logger.Debug(header);
                    String2 type = header[Define.PROTOCOL_CONNECTION];
                    if (type == null)
                    {
                        throw new Exception("header errer");
                    }
                    type = type.ToUpper();
                    if (type.Equals(Define.KEEP_ALIVE))
                    {
                        //This source is necessary that is modified.
                        IWorkWebClient webclient = WorkWebFactory.GetWorkWebServer().CreateWebClient(client);
                        webclient.Initialize(header);
                        WebController.NewInstance(webclient);
                    }
                    else if (type.Equals(Define.UPGRADE))
                    {
                        IWorkSocketClient socketclient = WorkSocketFactory.GetWorkSocketServer().CreateSocketClient(client);
                        socketclient.Initialize(header["Sec-WebSocket-Key"]);
                        SocketController control = SocketController.NewInstance(socketclient);
                        socketclient.SetReceiveEvent(control.SetReceive());
                    }
                    else
                    {
                        logger.Error(type);
                        throw new Exception("header errer");
                    }
                }
                catch (Exception e)
                {
                    logger.Error(e);
                    client.Close();
                }
            };
            server.ServerStart();
        }