Binary command

Jan 13, 2013 at 7:22 AM


   I have few commands, all works fin, but I want to add new command without corrupt any other command, but this one will work in binary format, mean send and receive binary data.

Can I implement mex commands?

I look on the code:

But the code not so clear to me, and its hard to see how to convert my command to binary, if I have the following command, how I can change it to switch to binary mode?

 public class WINOPC : JsonSubCommand<WebSocketServerSession, WindowOpenedRequest>
        class ThreadInfo
            public WebSocketServerSession session { get; set; }
            public WindowOpenedRequest commandInfo { get; set; }
        protected override void ExecuteJsonCommand(WebSocketServerSession session, WindowOpenedRequest commandInfo)
            ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessWINOPCommand), new ThreadInfo { commandInfo = commandInfo, session = session });

        private void ProcessWINOPCommand(object param)
            ThreadInfo threadInfo = param as ThreadInfo;
            WebSocketServerSession session = threadInfo.session;
            WindowOpenedRequest commandInfo = threadInfo.commandInfo;

            var response = CommandKeys.WINDOW_OPEND_RESPONSE + " " + SerializeObject(new WindowOpenedMessage
                WindowID = commandInfo.WindowID,
                LocationX = commandInfo.LocationX,
                LocationY = commandInfo.LocationY,
                Width = commandInfo.Width,
                Height = commandInfo.Height,
                Image = commandInfo.Image

            foreach (var s in commandInfo.TargetToken)
                var targetSession = session.AppServer.GetAppSessionByIndentityKey(s);

                if (targetSession != null)

            SendJsonResponse(session, CommandKeys.COMMAND_DONE_RESPOND, null);


Jan 15, 2013 at 8:58 AM

You should handle binary data in the handler of the event NewDataReceived of websocket server. Then you can convert the received binary data to RequestInfo instances and then pass them to commands.

Jan 15, 2013 at 9:30 AM

"You should handle binary data in the handler of the event NewDataReceived of websocket server" : but then all existed commands will be binary?

Or server will be able to manage both, keep support existed commands and will add new Binary commands?

Jan 15, 2013 at 9:36 AM

This feature is not built in SuperWebSocket for now, but you can implement it by yourself.