public IResult JoinNCRoom(string roomId, string password = "")
        {
            lock (LOCK)
            {
                if (waitingRespond)
                {
                    throw new Exception("产生过未上锁的异步请求");
                }
                this.waitingRespond = true;
                isSendSucceful      = true;
                clientSocket.Send(MessageTranslate.EncapsulationInfo(MessageContent.加入答疑室, MessageType.请求, roomId, password), ar => { if (ar == baseResult.Faild.ToString())
                                                                                                                                      {
                                                                                                                                          isSendSucceful = false;
                                                                                                                                      }
                                  });

                while (waitingRespond)
                {
                    if (!isSendSucceful)
                    {
                        waitingRespond = false; return(new Result(baseResult.Faild, "发送send失败"));
                    }
                }
                //等待响应
                if (respondMessage["结果"] == baseResult.Successful.ToString())
                {
                    builder = respondMessage["创建者"];
                    callOMCS.JoinRoom(roomId, builder);
                    UserInfo.RoomID = roomId;
                    return(new Result(baseResult.Successful, respondMessage["描述"]));
                }
                return(new Result(baseResult.Faild, respondMessage["描述"]));
            }
        }
Ejemplo n.º 2
0
 public IResult JoinNCRoom(string roomId, string password = "")
 {
     lock (LOCK)
     {
         if (waitingRespond)
         {
             throw new Exception("产生过未上锁的异步请求");
         }
         this.waitingRespond = true;
         clientSocket.Send(MessageTranslate.EncapsulationInfo(MessageContent.加入答疑室, MessageType.请求, roomId, password));
         while (waitingRespond)
         {
         }                         //等待响应
         if (respondMessage["结果"] == baseResult.Successful.ToString())
         {
             callOMCS.JoinRoom(roomId, respondMessage["创建者"]);
             return(new Result(baseResult.Successful, respondMessage["描述"]));
         }
         return(new Result(baseResult.Faild, respondMessage["描述"]));
     }
 }