Ejemplo n.º 1
0
        static public void onOpenAction(WebSocket ws, StompMessageSerializer serializer)
        {
            Console.WriteLine("Server says : open");
            var connect = new StompMessage("CONNECT");

            connect["accept-version"] = "1.1";
            connect["heart-beat"]     = "10000,10000";
            ws.Send(serializer.Serialize(connect));
        }
Ejemplo n.º 2
0
        static public void onMessageAction(WebSocket ws, StompMessageSerializer serializer, string data, int clientId)
        {
            StompMessage msg = serializer.Deserialize(data);

            if (msg.Command == StompCommand.CONNECTED)
            {
                var sub = new StompMessage("SUBSCRIBE");
                sub["id"]          = "sub-" + clientId;
                sub["destination"] = "/topic/" + clientId;
                ws.Send(serializer.Serialize(sub));
            }
            else if (msg.Command == StompCommand.MESSAGE)
            {
                JObject jObj = JObject.Parse(msg.Body);
                string  rMsg = (string)jObj["msg"];
                Console.WriteLine(rMsg);
            }
        }