Esempio n. 1
0
        private void processSetupRoomResponse(string input_data_val)
        {
            string group_id_str = input_data_val.Substring(0, Protocols.FabricThemeProtocolClass.FABRIC_GROUP_ID_SIZE);
            string room_id_str  = input_data_val.Substring(Protocols.FabricThemeProtocolClass.FABRIC_GROUP_ID_SIZE);

            GroupClass group = this.GroupMgrObject().GetGroupByGroupIdStr(group_id_str);

            if (group != null)
            {
                group.SetRoomIdStr(room_id_str);
                int      session_array_size = group.GetSessionArraySize();
                object[] session_array      = group.GetSessionArray();
                //group->setSessionTableArray((SessionClass**)phwangArrayMgrGetArrayTable(group->sessionArrayMgr(), &session_array_size));
                //printf("++++++++++++++++++++++++++++++++++++++++++++%d\n", session_array_size);
                for (int i = 0; i < session_array_size; i++)
                {
                    SessionClass session = (SessionClass)session_array[i];
                    session.LinkObject().SetPendingSessionSetup3(session.BrowserThemeIdStr(), session.SessionIdStr(), "");
                }
            }
        }
Esempio n. 2
0
        private string processGetSessionDataRequest(string input_data_val)
        {
            this.debugIt(true, "processGetSessionDataRequest", "input_data_val = " + input_data_val);
            GetSessionDataRequestFormat format_data;

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(input_data_val)))
            {
                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(GetSessionDataRequestFormat));
                format_data = (GetSessionDataRequestFormat)deseralizer.ReadObject(ms);// //反序列化ReadObject
                this.debugIt(true, "processGetSessionDataRequest", "link_id = " + format_data.link_id);
                this.debugIt(true, "processGetSessionDataRequest", "session_id = " + format_data.session_id);
            }

            LinkClass link = this.LinkMgrObject().GetLinkByIdStr(format_data.link_id);

            if (link == null)
            {
                return(errorProcessGetSessionData(format_data.link_id, "null link"));
            }

            SessionClass session = link.SessionMgrObject().GetSessionByIdStr(format_data.session_id);

            if (session == null)
            {
                return(errorProcessGetSessionData(format_data.session_id, "null session"));
            }

            string data = session.GetPendingDownLinkData();

            /* send the response down */
            string response_data = this.dFabricResponseObject.GenerateGetSessionDataResponse(link.LinkIdStr(), session.SessionIdStr(), data);

            return(response_data);
        }
Esempio n. 3
0
        private string processPutSessionDataRequest(string input_data_val)
        {
            this.debugIt(true, "processPutSessionDataRequest", "input_data_val = " + input_data_val);
            PutSessionDataRequestFormat format_data;

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(input_data_val)))
            {
                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(PutSessionDataRequestFormat));
                format_data = (PutSessionDataRequestFormat)deseralizer.ReadObject(ms);// //反序列化ReadObject
                this.debugIt(true, "processPutSessionDataRequest", "link_id = " + format_data.link_id);
                this.debugIt(true, "processPutSessionDataRequest", "session_id = " + format_data.session_id);
                this.debugIt(true, "processPutSessionDataRequest", "xmt_seq = " + format_data.xmt_seq);
                this.debugIt(true, "processPutSessionDataRequest", "data = " + format_data.data);
            }

            LinkClass    link    = this.LinkMgrObject().GetLinkById(format_data.link_id);
            SessionClass session = link.SessionMgrObject().GetSessionBySessionId(format_data.session_id);

            if (session == null)
            {
                return(errorProcessPutSessionData(format_data.link_id, "null session"));
            }
            string room_id_str = session.GroupObject().RoomIdStr();

            if (room_id_str == null)
            {
                return(this.errorProcessPutSessionData(format_data.link_id, "null room"));
            }

            /* transfer data up */
            string uplink_data = Protocols.FabricThemeProtocolClass.FABRIC_THEME_PROTOCOL_COMMAND_IS_PUT_ROOM_DATA;

            //uplink_data = uplink_data + room_id_str + link.LinkIdStr() + session.SessionIdStr();
            uplink_data = uplink_data + room_id_str + format_data.data;
            this.UFabricObject().TransmitData(uplink_data);

            /* send the response down */
            string response_data = this.dFabricResponseObject.GeneratePutSessionDataResponse(link.LinkIdStr(), session.SessionIdStr(), "job is done");

            return(response_data);
        }
Esempio n. 4
0
        private string processSetupSession3Request(string input_data_val)
        {
            this.debugIt(true, "processSetupSession3Request", "input_data_val = " + input_data_val);
            SetupSession3RequestFormat format_data;

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(input_data_val)))
            {
                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(SetupSession3RequestFormat));
                format_data = (SetupSession3RequestFormat)deseralizer.ReadObject(ms);// //反序列化ReadObject
                this.debugIt(true, "processSetupSession3Request", "link_id = " + format_data.link_id);
                this.debugIt(true, "processSetupSession3Request", "session_id = " + format_data.session_id);
            }

            LinkClass    link    = this.LinkMgrObject().GetLinkById(format_data.link_id);
            SessionClass session = link.SessionMgrObject().GetSessionBySessionId(format_data.session_id);

            if (session == null)
            {
                return(errorProcessSetupSession3(format_data.link_id, "null session"));
            }

            string response_data = this.dFabricResponseObject.GenerateSetupSession3Response(link.LinkIdStr(), session.SessionIdStr(), session.BrowserThemeIdStr());

            return(response_data);
        }
Esempio n. 5
0
        private string processSetupSessionRequest(string input_data_val)
        {
            this.debugIt(true, "processSetupSessionRequest", "input_data_val = " + input_data_val);
            SetupSessionRequestFormat format_data;

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(input_data_val)))
            {
                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(SetupSessionRequestFormat));
                format_data = (SetupSessionRequestFormat)deseralizer.ReadObject(ms);// //反序列化ReadObject
                this.debugIt(true, "processSetupSessionRequest", "link_id = " + format_data.link_id);
                this.debugIt(true, "processSetupSessionRequest", "his_name = " + format_data.his_name);
                this.debugIt(true, "processSetupSessionRequest", "theme_data = " + format_data.theme_data);
            }

            string theme_id_str = format_data.theme_data.Substring(0, Protocols.FabricFrontEndProtocolClass.BROWSER_THEME_ID_SIZE);
            string theme_data   = format_data.theme_data.Substring(Protocols.FabricFrontEndProtocolClass.BROWSER_THEME_ID_SIZE);

            LinkClass    link    = this.LinkMgrObject().GetLinkByIdStr(format_data.link_id);
            SessionClass session = link.MallocSession();

            session.SetBrowserThemeIdStr(theme_id_str);
            GroupClass group = this.GroupMgrObject().MallocGroup(theme_data);

            if (group == null)
            {
                return(this.errorProcessSetupSession(format_data.link_id, "null group"));
            }
            group.InsertSession(session);
            session.BindGroup(group);

            if (format_data.his_name == link.MyName())
            {
                this.mallocRoom(group, theme_data);
            }
            else
            {
                LinkClass his_link = this.LinkMgrObject().GetLinkByMyName(format_data.his_name);
                if (his_link == null)
                {
                    return(this.errorProcessSetupSession(format_data.link_id, "his_link does not exist"));
                }
                SessionClass his_session = his_link.MallocSession();
                if (his_session == null)
                {
                    return(this.errorProcessSetupSession(format_data.link_id, "null his_session"));
                }

                group.InsertSession(his_session);
                his_session.BindGroup(group);

                his_link.SetPendingSessionSetup(his_link.LinkIdStr() + his_session.SessionIdStr(), theme_data);
            }
            //char* data_ptr;
            //char* downlink_data = data_ptr = (char*)phwangMalloc(LINK_MGR_DATA_BUFFER_SIZE + 4, "DFS1");
            //*data_ptr++ = WEB_FABRIC_PROTOCOL_RESPOND_IS_SETUP_SESSION;
            //memcpy(data_ptr, ajax_id, WEB_FABRIC_PROTOCOL_AJAX_ID_SIZE);
            //data_ptr += WEB_FABRIC_PROTOCOL_AJAX_ID_SIZE;
            //strcpy(data_ptr, session->sessionIdIndex());
            //this->transmitFunction(tp_transfer_object_val, downlink_data);

            string response_data = this.dFabricResponseObject.GenerateSetupSessionResponse(link.LinkIdStr(), session.SessionIdStr());

            return(response_data);
        }
Esempio n. 6
0
        private string processGetLinkDataRequest(string input_data_val)
        {
            this.debugIt(true, "processGetLinkDataRequest", "input_data_val = " + input_data_val);
            GetLinkDataRequestFormat format_data;

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(input_data_val)))
            {
                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(GetLinkDataRequestFormat));
                format_data = (GetLinkDataRequestFormat)deseralizer.ReadObject(ms);// //反序列化ReadObject
                this.debugIt(true, "processGetLinkDataRequest", "link_id = " + format_data.link_id);
            }

            LinkClass link = this.LinkMgrObject().GetLinkById(format_data.link_id);

            string downlink_data = RESPONSE_IS_GET_LINK_DATA_NAME_LIST + this.FabricRootObject().NameListObject().NameListTagStr();

            int max_session_table_array_index = link.GetSessionArrayMaxIndex();

            PhwangUtils.ListEntryClass[] session_table_array = link.GetSessionArrayEntryTable();
            string pending_session_data = "";

            for (int i = 0; i <= max_session_table_array_index; i++)
            {
                PhwangUtils.ListEntryClass list_entry = session_table_array[i];
                SessionClass session = (SessionClass)list_entry.Data();
                if (session != null)
                {
                    if (session.GetPendingDownLinkDataCount() > 0)
                    {
                        downlink_data = downlink_data + Protocols.FabricFrontEndProtocolClass.WEB_FABRIC_PROTOCOL_RESPOND_IS_GET_LINK_DATA_PENDING_DATA + link.LinkIdStr() + session.SessionIdStr();
                    }
                }
            }

            /*
             *
             * int max_session_table_array_index = phwnagListMgrGetMaxIndex(link->sessionListMgrObject(), "DFabricClass::processGetLinkDataRequest()");
             * SessionClass** session_table_array = (SessionClass**)phwangListMgrGetEntryTableArray(link->sessionListMgrObject());
             * for (int i = 0; i <= max_session_table_array_index; i++)
             * {
             *  SessionClass* session = session_table_array[i];
             *  if (session)
             *  {
             *      char* pending_downlink_data = session->getPendingDownLinkData();
             *      if (pending_downlink_data)
             *      {
             * data_ptr++ = WEB_FABRIC_PROTOCOL_RESPOND_IS_GET_LINK_DATA_PENDING_DATA;
             *          session->enqueuePendingDownLinkData(pending_downlink_data);
             *          strcpy(data_ptr, link->linkIdIndex());
             *          data_ptr += LINK_MGR_PROTOCOL_LINK_ID_INDEX_SIZE;
             *          strcpy(data_ptr, session->sessionIdIndex());
             *          data_ptr += LINK_MGR_PROTOCOL_SESSION_ID_INDEX_SIZE;
             *          this->debug(true, "==================processGetLinkData getPendingDownLinkData", downlink_data);
             *      }
             *  }
             * }
             */



            string pending_session_setup = "";
            string pending_session_str   = link.getPendingSessionSetup();

            if (pending_session_str != null)
            {
                pending_session_setup = pending_session_setup + Protocols.FabricFrontEndProtocolClass.WEB_FABRIC_PROTOCOL_RESPOND_IS_GET_LINK_DATA_PENDING_SESSION;
                pending_session_setup = pending_session_setup + pending_session_str;
            }

            string pending_session_str3 = link.getPendingSessionSetup3();

            if (pending_session_str3 != null)
            {
                pending_session_setup = pending_session_setup + Protocols.FabricFrontEndProtocolClass.WEB_FABRIC_PROTOCOL_RESPOND_IS_GET_LINK_DATA_PENDING_SESSION3;
                pending_session_setup = pending_session_setup + pending_session_str3;
            }

            downlink_data = downlink_data + pending_session_setup;

            string response_data = this.dFabricResponseObject.GenerateGetLinkDataResponse(link.LinkIdStr(), downlink_data, pending_session_setup);

            return(response_data);
        }