Esempio n. 1
0
        protected override void NewConnection(object sender, SocketArgs args)
        {
            try
            {
                string request = string.Format(
                    "GET {0} HTTP/1.1" + Environment.NewLine +
                    "Upgrade: WebSocket" + Environment.NewLine +
                    "Connection: Upgrade" + Environment.NewLine +
                    "Host: {1}" + Environment.NewLine +
                    "Origin: {2}" + Environment.NewLine +
                    "Pragma: no-cache" + Environment.NewLine +
                    "Cache-Control: no-cache" + Environment.NewLine +
                    "Accept-Encoding: gzip, deflate" + Environment.NewLine +
                    "Sec-WebSocket-Version: 13" + Environment.NewLine +
                    "Sec-WebSocket-Key: " + Hybi.GenerateKey() + "" + Environment.NewLine +
                    "Sec-WebSocket-Extensions: permessage-deflate; client_no_context_takeover; server_no_context_takeover" +
                    Environment.NewLine + Environment.NewLine, "/", args.Socket.Endpoint, "null");

                if (!this.SendRaw(Utils.ToLatin(request)))
                {
                    Console.WriteLine("Sendraw failed?");
                    throw new Exception("Sendraw failed?");
                }
            }
            catch (ObjectDisposedException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
        }
Esempio n. 2
0
 internal void RaiseConnection(SocketArgs Args)
 {
     if (Connection != null)
     {
         Connection(this, Args);
     }
 }
Esempio n. 3
0
        private void Connected(object sender, SocketArgs e)
        {
            if (e == null)
            {
                return;
            }
            if (Connection == null)
            {
                return;
            }

            Connection Ctx = Connection(this, new TextArgs("Conntected: " + e.Socket.Endpoint));

            if (Ctx == null)
            {
                return;
            }

            Ctx.Closed  += Socket_Closed;
            Ctx.Command += Data_Command;

            Ctx.Start(e.Socket);
        }
Esempio n. 4
0
 protected virtual void NewConnection(object sender, SocketArgs args)
 {
 }
Esempio n. 5
0
 private void Raw_Connected(object sender, SocketArgs args)
 {
     this.NewConnection(sender, args);
 }