public void SocketOptionCookies()
 {
     var options = new Socket.Options();
     options.Cookies.Add("foo", "bar");
     Assert.Equal("foo=bar", options.GetCookiesAsString());
     options.Cookies.Add("name2", "value2");
     Assert.Equal("foo=bar; name2=value2", options.GetCookiesAsString());
 }
        protected Socket.Options CreateOptions()
        {
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());

            var config = ConfigBase.Load();
            var options = new Socket.Options();
            options.Port = config.server.port;
            options.Hostname = config.server.hostname;
            log.Info("Please add to your hosts file: 127.0.0.1 " + options.Hostname);

            return options;
        }
        protected Socket.Options CreateOptions()
        {
            LogManager.SetupLogManager();
            var log = LogManager.GetLogger(Global.CallerName());

            var config = ConfigBase.Load();
            var options = new Socket.Options();
            options.Port = config.server.port;
            options.Hostname = config.server.hostname;
            log.Info("Please add to your hosts file: 127.0.0.1 " + options.Hostname);

            return options;
        }
        protected Socket.Options CreateOptionsSecure()
        {
            LogManager.SetupLogManager();
            var log = LogManager.GetLogger(Global.CallerName());

            var config = ConfigBase.Load();
            var options = new Socket.Options();
            options.Port = config.server.ssl_port;
            options.Hostname = config.server.hostname;
            log.Info("Please add to your hosts file: 127.0.0.1 " + options.Hostname);
            options.Secure = true;
            options.IgnoreServerCertificateValidation = true;
            return options;
        }
        protected Socket.Options CreateOptionsSecure()
        {
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());

            var config = ConfigBase.Load();
            var options = new Socket.Options();
            options.Port = config.server.ssl_port;
            options.Hostname = config.server.hostname;
            log.Info("Please add to your hosts file: 127.0.0.1 " + options.Hostname);
            options.Secure = true;
            options.IgnoreServerCertificateValidation = true;
            return options;
        }
        static void Main(string[] args) {
            Socket.Options opts = new Socket.Options();
            opts.Path = "live.eio";
            opts.Port = 443;
            opts.PolicyPort = 843;
            opts.Secure = true;
            opts.Hostname = "ws.www.livecoding.tv";
            opts.Transports = ImmutableList.Create<string>("websocket");

            Socket socket = new Socket("www.livecoding.tv", opts);
            socket.On("connect", (fn) => {
                Console.WriteLine(TimeStamp() + "\r\nConnected event...\r\n");
            }); 
            
            socket.On("update", (data) => {
                Console.WriteLine(TimeStamp() + "recv [socket].[update] event");
                Console.WriteLine(TimeStamp() + "recv [socket].[update] data: " + data);
            }); 
            
            socket.On("message", (data) => {
                Console.WriteLine(TimeStamp() + "recv [socket].[message] event");
                string message = ""; //= Encoding.UTF8.GetString((byte[])data);
                if (data.GetType() == typeof(string)) {
                    message = (string)data;
                } else if (data.GetType() == typeof(byte[])) {
                    message = Encoding.UTF8.GetString((byte[])data);
                } else {
                    message = data.ToString();
                }
                Console.WriteLine(TimeStamp() + "recv [socket].[message] data: " + message);
            }); 
            
            socket.On("open", (data) => { 
                string json = @"['join','stream.callumc']";
                json = json.Replace("'", "\"");
                Console.WriteLine(TimeStamp() + "CONNECTED (" + data + "), sending channels : " + json);
                socket.Send(Encoding.UTF8.GetBytes(json));
            });

            socket.On(Socket.EVENT_ERROR, (data) => {
                EngineIOException exception = (EngineIOException)(data);
                Console.WriteLine(TimeStamp() + "Could not connect " + exception.StackTrace); 
            });


            socket.On("noop", (data) => {
                Console.WriteLine(TimeStamp() + "Noop: " + data);
            });

            socket.On(Socket.EVENT_HANDSHAKE, (data) => { Console.WriteLine(TimeStamp() + "Connection Handshake : " + data); });
            socket.On(Socket.EVENT_HEARTBEAT, () => { Console.WriteLine(TimeStamp() + "HeartBeat"); });
            socket.On(Socket.EVENT_OPEN, () => { Console.WriteLine(TimeStamp() + "SOCKET OPENED"); });
            socket.On(Socket.EVENT_CLOSE, () => { Console.WriteLine(TimeStamp() + "SOCKET CLOSED"); });
            socket.On(Socket.EVENT_HANDSHAKE, () => { Console.WriteLine(TimeStamp() + "SOCKET HANDSHAKE"); });
            socket.On(Socket.EVENT_PACKET, (data) => { 
                Quobject.EngineIoClientDotNet.Parser.Packet packet = ((Quobject.EngineIoClientDotNet.Parser.Packet)data);
                Console.WriteLine(TimeStamp() + "SOCKET PACKET  " + packet.Type); 
            });
            socket.On(Socket.EVENT_UPGRADE, () => { Console.WriteLine(TimeStamp() + "SOCKET UPGRADE"); });
            socket.On(Socket.EVENT_DRAIN, () => { Console.WriteLine(TimeStamp() + "SOCKET DRAINED"); });
            socket.On(Socket.EVENT_FLUSH, () => { Console.WriteLine(TimeStamp() + "SOCKET FLUSHED"); });
            socket.On(Socket.EVENT_PACKET_CREATE, () => { Console.WriteLine(TimeStamp() + "SOCKET PACKET CREATED"); });
            socket.On(Socket.EVENT_TRANSPORT, (dat) => { Console.WriteLine(TimeStamp() + "SOCKET TRANSPORT"); });
            socket.Open();

            do { } while (true);
        }