public static void DeleteInstance()
 {
     if (NpCloudManager.instance != null)
     {
         NpCloudManager.instance.mListenerlist.Clear();
         NpCloudManager.instance.mListenerlist = null;
         NpCloudManager.instance.mChatSystem.ClearData();
         NpCloudManager.instance.mRoomSystem.ClearData();
         NpCloudManager.instance.mChatSystem = null;
         NpCloudManager.instance.mRoomSystem = null;
     }
     NpCloudManager.instance = null;
 }
        public void GetRoomMsgLog(string roomId, int limit)
        {
            NpChatLogRequestParameter npChatLogRequestParameter = new NpChatLogRequestParameter();

            npChatLogRequestParameter.roomId = roomId;
            npChatLogRequestParameter.limit  = limit;
            NpCloudServerData npCloudServerData = new NpCloudServerData();

            npCloudServerData.content = npChatLogRequestParameter;
            npCloudServerData.type    = NpCloudType.direct;
            npCloudServerData.ctrl    = "9202";
            npCloudServerData.value   = NpCloudValueType.chathis;
            NpCloudManager.GetInstance().Request(npCloudServerData);
        }
        public void SendRoomMessage(string roomId, string message)
        {
            NpChatRequestParameter npChatRequestParameter = new NpChatRequestParameter();

            npChatRequestParameter.msg.Add(message);
            npChatRequestParameter.ngcheck = 1;
            npChatRequestParameter.roomId  = roomId;
            npChatRequestParameter.to      = NpCloudManager.GetInstance().GetUserList(roomId);
            NpCloudServerData npCloudServerData = new NpCloudServerData();

            npCloudServerData.value   = NpCloudValueType.send;
            npCloudServerData.type    = NpCloudType.direct;
            npCloudServerData.content = npChatRequestParameter;
            npCloudServerData.ctrl    = "9201";
            NpCloudManager.GetInstance().Request(npCloudServerData);
        }
 public static void CreateInstance(INpCloudManager listener)
 {
     if (NpCloudManager.instance != null)
     {
         return;
     }
     NpCloudManager.instance                              = new NpCloudManager(listener);
     NpCloudManager.instance.mRoomSystem                  = new NpCloudRoomSystem();
     NpCloudManager.instance.mRoomSystem.JoinRoom         = new Action <NpRoomParameter>(NpCloudManager.instance.mListener.OnJoinRoom);
     NpCloudManager.instance.mRoomSystem.LeaveRoom        = new Action <NpLeaveParameter>(NpCloudManager.instance.mListener.OnLeaveRoom);
     NpCloudManager.instance.mRoomSystem.RequestException = new Action <NpCloudErrorData>(NpCloudManager.instance.mListener.OnRequestException);
     NpCloudManager.instance.AddListener(NpCloudManager.instance.mRoomSystem);
     NpCloudManager.instance.mChatSystem                  = new NpCloudChatSystem();
     NpCloudManager.instance.mChatSystem.Message          = new Action <NpMessageParameter>(NpCloudManager.instance.mListener.OnMessage);
     NpCloudManager.instance.mChatSystem.RoomMsgLog       = new Action <List <NpRoomMsgLog> >(NpCloudManager.instance.mListener.OnRoomMsgLog);
     NpCloudManager.instance.mChatSystem.RequestException = new Action <NpCloudErrorData>(NpCloudManager.instance.mListener.OnRequestException);
     NpCloudManager.instance.AddListener(NpCloudManager.instance.mChatSystem);
 }
Example #5
0
 private bool Join(string command, NpCloudReceiveRoomParameter response, long resTime)
 {
     if (command.Equals("9100"))
     {
         bool            isNewMember     = true;
         NpRoomParameter npRoomParameter = new NpRoomParameter(RoomJoinTypeE.Create, response.room_id, response.room_name, (RoomType)response.room_type, (int)NpCloudManager.GetInstance().UserID, isNewMember, response.owner, response.member_list, new List <RoomCondition>(), NpUtil.MsTimestampToDateTime(resTime));
         if (response.room_condition != null)
         {
             npRoomParameter.RoomCondition = response.room_condition;
         }
         List <int> member_list = response.member_list;
         if (!this.mJoinRoomList.ContainsKey(npRoomParameter.RoomId))
         {
             this.mJoinRoomList.Add(npRoomParameter.RoomId, npRoomParameter);
             this.mUserList.Add(npRoomParameter.RoomId, member_list);
         }
         else
         {
             this.mUserList[npRoomParameter.RoomId]     = member_list;
             this.mJoinRoomList[npRoomParameter.RoomId] = npRoomParameter;
         }
         this.mJoinRoom(npRoomParameter);
         return(true);
     }
     if (command.Equals("9102"))
     {
         NpRoomParameter npRoomParameter2 = new NpRoomParameter(RoomJoinTypeE.RoomJoin, response.room_id, response.room_name, (RoomType)response.room_type, response.member_joined, response.is_new_member != 0, response.owner, response.member_list, new List <RoomCondition>(), NpUtil.MsTimestampToDateTime(resTime));
         if (response.room_condition != null)
         {
             npRoomParameter2.RoomCondition = response.room_condition;
         }
         List <int> member_list2 = response.member_list;
         if (!this.mJoinRoomList.ContainsKey(npRoomParameter2.RoomId))
         {
             this.mJoinRoomList.Add(npRoomParameter2.RoomId, npRoomParameter2);
             this.mUserList.Add(npRoomParameter2.RoomId, member_list2);
         }
         else
         {
             this.mUserList[npRoomParameter2.RoomId]     = member_list2;
             this.mJoinRoomList[npRoomParameter2.RoomId] = npRoomParameter2;
         }
         this.mJoinRoom(npRoomParameter2);
         return(true);
     }
     return(false);
 }