Olivine-Labs / Alchemy-Websockets

An extremely efficient C# WebSocket server.
http://AlchemyWebsockets.net
Other
309 stars 105 forks source link

WebSocketClient error right after connecting in SetupContext() #78

Open grok314 opened 11 years ago

grok314 commented 11 years ago

I am running into an error that seems to occur right after connecting to the Server. I actually see "Connected!" show up in the console window. I have a Chrome browser connecting to the server and receiving messages with no problems.

If someone could look at my code and let me know what I'm doing wrong, that would be very helpful.

Thank You

error location

static void Main(string[] args)
        {
            var aClient = new WebSocketClient(@"ws://www.privateurl.com:1234/")
            {
                OnReceive = OnReceive,
                OnSend = OnSend,
                OnConnect = OnConnected,
                OnConnected = OnConnect,
                OnDisconnect = OnDisconnect
            };
            aClient.SubProtocols = new string[] { "novachem-client" };

            aClient.Connect();
            //aClient.Send("Hey!"); // string or byte[]
            //aClient.Disconnect();

            System.Threading.Thread.Sleep(0);
        }
        static void OnSend(UserContext context)
        {
            //Console.WriteLine("The server said : " + context.DataFrame.ToString());
        }
        static void OnConnected(UserContext context)
        {
            Console.WriteLine("Connected!");
        }
        static void OnConnect(UserContext context)
        {
            Console.WriteLine("Connect event");
        }
        static void OnDisconnect(UserContext context)
        {
            Console.WriteLine("Disconnected!");
        }
        static void OnReceive(UserContext context)
        {
            Console.WriteLine("The server said : " + context.DataFrame.ToString());
        }