Пример #1
0
 void Status(object sender, TextArgs e)
 {
     if (WriteLine != null)
     {
         WriteLine(sender, e);
     }
 }
Пример #2
0
        private Connection Connected(object sender, TextArgs Args)
        {
            //if (WriteLine != null) WriteLine(this, Args);

            Peer pp = new Peer(Server.Local);

            return(new Connection(pp, Server.Local));
        }
Пример #3
0
        protected override void NewHeader(object sender, TextArgs args)
        {
            if (!args.Message.Contains("HTTP/1.1 101"))
            {
                Close("NewHeader");
                return;
            }

            WebData.handshakeComplete = true;

            base.RaiseConnection();
        }
Пример #4
0
        protected override void NewHeader(object sender, TextArgs args)
        {
            string       sKey   = "";
            var          writer = new StringBuilder();
            StringReader Sr     = new StringReader(args.Message);

            writer.AppendLine("HTTP/1.1 101 Switching Protocols");

            while (Sr.Peek() > 0)
            {
                string Line = Sr.ReadLine();

                if (Line.StartsWith("Upgrade:"))
                {
                    writer.AppendLine(Line);
                }

                if (Line.StartsWith("Connection:"))
                {
                    writer.AppendLine(Line);
                }

                if (Line.StartsWith("Sec-WebSocket-Key:"))
                {
                    sKey = Line.Substring(18).Trim();
                }

                if (Line.StartsWith("Sec-WebSocket-Extensions:"))
                {
                    if (Line.Contains("permessage-deflate"))
                    {
                        bool DoDeflate = !base.Local;
#if DEBUG
                        DoDeflate = true;
#endif
                        if (DoDeflate)
                        {
                            base.Encoder = new DataStream();
                            writer.AppendLine("Sec-WebSocket-Extensions: permessage-deflate; client_no_context_takeover; server_no_context_takeover");
                        }
                    }
                }
            }

            if (sKey.Length == 0)
            {
                Close("sKey.Length");
                return;
            }

            writer.AppendLine("Sec-WebSocket-Version: 13");
            writer.AppendLine("Sec-WebSocket-Accept: " + Handshake(sKey));
            writer.AppendLine("");

            string sOut = writer.ToString().Replace(Environment.NewLine, "\r\n");

            if (!base.SendRaw(Utils.ToUTF(sOut)))
            {
                Console.WriteLine("Sendraw failed?");
                throw new Exception("Sendraw failed?");
            }

            WebData.handshakeComplete = true;
        }
Пример #5
0
 public JsonArgs(TextArgs vJson, Connection vContext) : base(vContext)
 {
     Json = vJson;
 }
Пример #6
0
 void Retry_TimerEvent(object sender, TextArgs e)
 {
     TimerEvent(sender, e);
 }
Пример #7
0
 protected virtual void NewHeader(object sender, TextArgs args)
 {
 }
Пример #8
0
 private void Data_Header(object sender, TextArgs args)
 {
     this.NewHeader(sender, args);
 }
Пример #9
0
        private void Raw_Closed(object sender, TextArgs e)
        {
            CloseArgs cA = new CloseArgs(e.Message, true);

            Raise_Closed(cA);
        }
Пример #10
0
 void SslSocket_Closed(object sender, TextArgs e)
 {
     Close(e.Message, false);
 }