Beispiel #1
0
        private void ProcessChatMsg(RSProtoBuffSSHMsg msg)
        {
            EventChatMessage response = new EventChatMessage();
            Exception        e;

            if (RSProtoBuf.Deserialize <EventChatMessage>(msg.ProtoBuffMsg, out response, out e))
            {
                switch (response.msg.id.chat_type)
                {
                case ChatType.TYPE_GROUP:
                    //_b.ChatProcessor.AddMsgToGroupChat(response);
                    _b.ChatProcessor.AddMsgToLobby(ChatProcessor.BROADCAST, response.msg);
                    break;

                case ChatType.TYPE_LOBBY:
                    _b.ChatProcessor.AddMsgToLobby(response.msg.id.chat_id, response.msg);
                    break;

                case ChatType.TYPE_PRIVATE:
                    break;

                default:
                    System.Diagnostics.Debug.WriteLineIf(DEBUG, "ProcessChatMsg: unknown chat type");
                    break;
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessChatMsg: error deserializing " + e.Message);
            }
        }
Beispiel #2
0
        private void ProcessSystemAccount(RSProtoBuffSSHMsg msg)
        {
            ResponseSystemAccount response = new ResponseSystemAccount();
            Exception             e;

            if (RSProtoBuf.Deserialize <ResponseSystemAccount>(msg.ProtoBuffMsg, out response, out e))
            {
                _b.PeerProcessor.SetOwnID(response);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessSystemstatus: error deserializing " + e.Message);
            }
        }
Beispiel #3
0
        private void ProcessSystemStatus(RSProtoBuffSSHMsg msg)
        {
            ResponseSystemStatus response = new ResponseSystemStatus();
            Exception            e;

            if (RSProtoBuf.Deserialize <ResponseSystemStatus>(msg.ProtoBuffMsg, out response, out e))
            {
                _b.GUI.UpdateSystemStatus(response);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessSystemstatus: error deserializing " + e.Message);
            }
        }
Beispiel #4
0
        private void ProcessControllDownload(RSProtoBuffSSHMsg msg)
        {
            ResponseControlDownload response = new ResponseControlDownload();
            Exception e;

            if (RSProtoBuf.Deserialize <ResponseControlDownload>(msg.ProtoBuffMsg, out response, out e))
            {
                _b.GUI.tb_out.AppendText("ReqContrDL response:" + response.status.code + "\n");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessControllDownload: error deserializing " + e.Message);
            }
        }
Beispiel #5
0
        private void ProcessSendMsg(RSProtoBuffSSHMsg msg)
        {
            ResponseSendMessage response = new ResponseSendMessage();
            Exception           e;

            if (RSProtoBuf.Deserialize <ResponseSendMessage>(msg.ProtoBuffMsg, out response, out e))
            {
                _b.GUI.tb_out.AppendText("ReqSendMsg response:" + response.status.code + "\n");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessChatMsg: error deserializing " + e.Message);
            }
        }
Beispiel #6
0
        private void ProcessLobbyInvite(RSProtoBuffSSHMsg msg)
        {
            EventLobbyInvite response = new EventLobbyInvite();
            Exception        e;

            if (RSProtoBuf.Deserialize <EventLobbyInvite>(msg.ProtoBuffMsg, out response, out e))
            {
                _b.ChatProcessor.LobbyInvite(response);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessChatMsg: error deserializing " + e.Message);
            }
        }
Beispiel #7
0
        private void ProcessShareDirList(RSProtoBuffSSHMsg msg)
        {
            ResponseShareDirList response = new ResponseShareDirList();
            Exception            e;

            if (RSProtoBuf.Deserialize <ResponseShareDirList>(msg.ProtoBuffMsg, out response, out e))
            {
                if (response.status.code == Status.StatusCode.SUCCESS)
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessShareDirList: error deserializing " + e.Message);
            }
        }
Beispiel #8
0
        private void ProcessChatLobbies(RSProtoBuffSSHMsg msg)
        {
            ResponseChatLobbies response = new ResponseChatLobbies();
            Exception           e;

            if (RSProtoBuf.Deserialize <ResponseChatLobbies>(msg.ProtoBuffMsg, out response, out e))
            {
                if (response.status.code == Status.StatusCode.SUCCESS)
                {
                    _b.ChatProcessor.UpdateChatLobbies(response);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessChatMsg: error deserializing " + e.Message);
            }
        }
Beispiel #9
0
        //private void ProcessAddPeer(RSProtoBuffSSHMsg msg)
        //{
        //    Respon response = new ResponseAddPeer();
        //    Exception e;
        //    if (RSProtoBuf.Deserialize<ResponseAddPeer>(msg.ProtoBuffMsg, out response, out e))
        //        _b.GUI.tb_out.AppendText("AddPeer response: " + response.status.code + "\n");
        //    else
        //        System.Diagnostics.Debug.WriteLine("ProcessAddPeer: error deserializing " + e.Message);
        //}

        //private void ProcessModifyPeer(RSProtoBuffSSHMsg msg)
        //{
        //    ResponseModifyPeer response = new ResponseModifyPeer();
        //    Exception e;
        //    if (RSProtoBuf.Deserialize<ResponseModifyPeer>(msg.ProtoBuffMsg, out response, out e))
        //        _b.GUI.tb_out.AppendText("AddPeer response: " + response.status.code + "\n");
        //    else
        //        System.Diagnostics.Debug.WriteLine("ProcessModifyPeer: error deserializing " + e.Message);
        //}

        private void ProcessPeerList(RSProtoBuffSSHMsg msg)
        {
            ResponsePeerList response = new ResponsePeerList();
            Exception        e;

            if (RSProtoBuf.Deserialize <ResponsePeerList>(msg.ProtoBuffMsg, out response, out e))
            {
                if (response.status.code == Status.StatusCode.SUCCESS)
                {
                    //_b.PeerProcessor.ProcessResponsePeerList(msg.ReqID, response);
                    _b.PeerProcessor.UpdatePeerList(response);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("ProcessPeerList: error deserializing " + e.Message);
                }
            }
        }
Beispiel #10
0
        private void ProcessTransferlist(RSProtoBuffSSHMsg msg)
        {
            ResponseTransferList response = new ResponseTransferList();
            Exception            e;

            if (RSProtoBuf.Deserialize <ResponseTransferList>(msg.ProtoBuffMsg, out response, out e))
            {
                if (response.status.code == Status.StatusCode.SUCCESS)
                {
                    _b.FileProcessor.UpdateFileTransfers(response, msg.ReqID);
                    //_b.FileProcessor.UpdateFileTransfersNEW(response, msg.ReqID);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessTransferlist: error deserializing " + e.Message);
            }
        }
Beispiel #11
0
        private void ProcessStreamData(RSProtoBuffSSHMsg msg)
        {
            ResponseStreamData response = new ResponseStreamData();
            Exception          e;

            if (RSProtoBuf.Deserialize <ResponseStreamData>(msg.ProtoBuffMsg, out response, out e))
            {
                if (response.status.code == Status.StatusCode.SUCCESS)
                {
                    _b.StreamProcessor.StreamData(response);
                }
                else
                {
                    _b.GUI.tb_out.AppendText("StreamData response: " + response.status.code + "\n");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessStreamData: error deserializing " + e.Message);
            }
        }
Beispiel #12
0
        private void ProcessSearchIDs(RSProtoBuffSSHMsg msg)
        {
            ResponseSearchIds response = new ResponseSearchIds();
            Exception         e;

            if (RSProtoBuf.Deserialize <ResponseSearchIds>(msg.ProtoBuffMsg, out response, out e))
            {
                if (response.status.code == Status.StatusCode.SUCCESS)
                {
                    _b.SearchProcessor.RegisterSearchIDs(msg.ReqID, response);
                }
                else
                {
                    _b.GUI.tb_out.AppendText("SearchIDs response: " + response.status.code + "\n");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ProcessSearchIDs: error deserializing " + e.Message);
            }
        }
Beispiel #13
0
        static private void ProcessMsgFromThread(RSProtoBuffSSHMsg msg)
        {
            System.Console.WriteLine("got msg");

            /*
             * So we received a RPC message. What do we know at this point?
             * We know that the magic code of the message is ok which means that the chance is high that the rest is ok, too.
             *
             *
             * First of all we should check if the message is a response.
             * Since the server only sends responses we do not expect anything else.
             *
             * Note: actually the lib is doing this on its own and you can skip this test.
             * (I keep it for educational purpose :P)
             */
            if (!RSProtoBuf.IsRpcMsgIdResponse(msg.MsgID))
            {
                return;
            }

            /*
             * Next step is to get the informations about the message:
             *      extension, service and submsg
             *
             * These 3 things define the content of the message.
             * (In this example i only requested the system status so i only expect a response to this call)
             */
            byte   extension = RSProtoBuf.GetRpcMsgIdExtension(msg.MsgID);
            ushort service   = RSProtoBuf.GetRpcMsgIdService(msg.MsgID);
            byte   submsg    = RSProtoBuf.GetRpcMsgIdSubMsg(msg.MsgID);

            // check extension
            if (extension != (byte)rsctrl.core.ExtensionId.CORE)
            {
                return;
            }

            // check service
            if (service != (ushort)rsctrl.core.PackageId.SYSTEM)
            {
                return;
            }

            // check submsg
            if (submsg != (byte)rsctrl.system.ResponseMsgIds.MsgId_ResponseSystemStatus)
            {
                return;
            }

            /*
             * Now we know the content of the message and can deserialize it
             * (The example message is a response to our system status request!)
             */

            rsctrl.system.ResponseSystemStatus response = new rsctrl.system.ResponseSystemStatus();
            Exception e;

            if (!RSProtoBuf.Deserialize <rsctrl.system.ResponseSystemStatus>(msg.ProtoBuffMsg, out response, out e))
            {
                System.Console.WriteLine("ProcessSystemstatus: error deserializing " + e.Message);
            }

            /*
             * Last thing you should do is to check if the response.status is SUCCESS.
             * In any other case something went wrong.
             *
             * After this you can continue processing the message in the proper way e.g. update system status
             */
            if (response.status == null || response.status.code != rsctrl.core.Status.StatusCode.SUCCESS)
            {
                return;
            }

            System.Console.WriteLine("Systemstatus: ");
            System.Console.WriteLine(" -- peers: " + response.no_peers);
            System.Console.WriteLine(" -- online: " + response.no_connected);
        }