internal void RaiseConnection(SocketArgs Args) { if (Connection != null) { Connection(this, Args); } }
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; } }
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); }
protected virtual void NewConnection(object sender, SocketArgs args) { }
private void Raw_Connected(object sender, SocketArgs args) { this.NewConnection(sender, args); }