Beispiel #1
0
        /// <summary>
        /// the delegate returns null if there was no default room found
        /// will also throw an error if the default room is not enabled in the xml or if the xml is not formatted correctly
        /// this does NOT add the room to the RoomManager cache
        /// </summary>
        /// <param name="userAccount"></param>
        /// <param name="getDefaultRoomFinishedCallback"></param>
        private void GetDefaultRoom(ServerAccount userAccount, System.Action <IServerDistributedRoom> getDefaultRoomFinishedCallback)
        {
            Action <XmlDocument> getDefaultRoomServiceCallback = delegate(XmlDocument xmlResponse)
            {
                IServerDistributedRoom returnedDefaultRoom = null;
                XmlNode defaultRoomXmlNode = xmlResponse.SelectSingleNode("Rooms/Room");
                //if the default Room is null, we want to create a new room and set that as the default room
                if (defaultRoomXmlNode != null)
                {
                    RoomProperties         roomProperties = RoomXmlUtil.GetRoomPropertiesFromXml(defaultRoomXmlNode, mServerStateMachine.ServerAssetRepository);
                    IServerDistributedRoom defaultRoom    = CreateServerDistributedRoom(roomProperties);
                    if (defaultRoom == null)
                    {
                        StateServerAssert.Assert(new System.Exception("Error: the default room is either not enabled or does not contain proper data: " + defaultRoomXmlNode.OuterXml));
                    }
                    else
                    {
                        //if the user's default room is already cached, we just return the room object we have stored
                        // otherwise we add the newly created defaultRoom to the roomManager cache
                        if (!mRoomIdToRoomDistributedObject.TryGetValue(defaultRoom.RoomId, out returnedDefaultRoom))
                        {
                            returnedDefaultRoom = defaultRoom;
                        }
                    }
                }
                getDefaultRoomFinishedCallback(returnedDefaultRoom);
            };

            RoomManagerServiceAPI.GetDefaultRoomService(userAccount.AccountId, getDefaultRoomServiceCallback);
        }
Beispiel #2
0
 protected void GetRoomFromRoomIdService(RoomId roomId, System.Action <IServerDistributedRoom> getRoomCallback)
 {
     RoomManagerServiceAPI.GetRoomService(roomId,
                                          delegate(XmlDocument xmlResponse)
     {
         RoomProperties roomProperties = RoomXmlUtil.GetRoomPropertiesFromXml(xmlResponse, mServerStateMachine.ServerAssetRepository);
         IServerDistributedRoom serverDistributedRoom = CreateServerDistributedRoom(roomProperties);
         getRoomCallback(serverDistributedRoom);
     });
 }