Exemplo n.º 1
0
 internal void RaiseConnection(SocketArgs Args)
 {
     if (Connection != null)
     {
         Connection(this, Args);
     }
 }
Exemplo n.º 2
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(MemoryUtils.ToLatin(request)))
                {
                    Console.WriteLine("Sendraw failed?");
                    throw new Exception("Sendraw failed?");
                }
            }
            catch (ObjectDisposedException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
        }
Exemplo 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);
        }
Exemplo n.º 4
0
 protected virtual void NewConnection(object sender, SocketArgs args)
 {
 }
Exemplo n.º 5
0
 private void Raw_Connected(object sender, SocketArgs args)
 {
     this.NewConnection(sender, args);
 }