Example #1
0
 static void Main(string[] args)
 {
     Console.WriteLine(ServerC.Access("127.0.0.1", 9840, 10, Accept).Info);
     while (true)
     {
         string cmd = Console.ReadLine();
         if (cmd == "shutdown")
         {
             break;
         }
         ServerC.Send(clients[0], "服务器发送信息:" + cmd);
     }
 }
Example #2
0
 public void SendFile(string filePath)
 {
     while (!IsConnected)
     {
         _autoResetEvent.WaitOne(10);
     }
     FileHelper.Read(filePath, (data) =>
     {
         _dataSocket.Send(_userToken.ID, data);
     });
     while (IsConnected)
     {
         _autoResetEvent.WaitOne(10);
     }
 }
Example #3
0
        //[AOPMethod("创建答疑室请求", PreProceed, PostProceed)]
        private IResult CreateRoomRequest(IReceiveInfo receiveInfo, UserInfo userInfo)
        {
            string roomID   = receiveInfo.Message["房间名"];
            string password = receiveInfo.Message["密码"];

            Terminal.ClientPrint(receiveInfo.RemoteEndPoint, InfoType.请求, "创建答疑室=>房间号:" + roomID);
            IResult result;

            if (!runningData.Clients_remoteEndPoint[receiveInfo.RemoteEndPoint].IsPrerogative)//权限判定
            {
                result = new Result(baseResult.Faild, "用户没有创建权限");
            }
            else if (runningData.ChatRoom_id.ContainsKey(roomID))//房间存在判定
            {
                result = new Result(baseResult.Faild, "该答疑室已存在");
            }
            else//成功创建
            {
                ChatRoom chatroom = new ChatRoom(password);
                chatroom.RoomEmpty += RoomEmpty;
                chatroom.Builder    = userInfo;
                chatroom.GroupName  = roomID;
                chatroom.memberList.Add(userInfo);
                runningData.ChatRoom_id[roomID] = chatroom;
                ((User_Server)userInfo).RoomIDs.Add(roomID);
                result = new Result(baseResult.Successful, "房间号" + roomID);
            }
            if (result.BaseResult == baseResult.Faild)
            {
                Terminal.ServerPrint(InfoType.响应, "<" + receiveInfo.RemoteEndPoint + ">:" + "创建失败 描述:" + result.Info);
            }
            else
            {
                Terminal.ServerPrint(InfoType.响应, "<" + receiveInfo.RemoteEndPoint + ">:" + "创建成功 描述:" + result.Info);
            }
            ServerSocket.Send(receiveInfo.RemoteEndPoint, MessageTranslate.EncapsulationInfo(MessageContent.创建答疑室, MessageType.响应, result.BaseResult.ToString(), result.Info));
            return(result);
        }
Example #4
0
 private void ClassificationBatcher_OnBatched(string name, byte[] data)
 {
     _serverSokcet.Send(name, data);
 }
Example #5
0
 public void Send(IUserToken userToken, byte[] data)
 {
     _serverSokcet.Send(userToken.ID, data);
 }
Example #6
0
 private void _exchange_OnBatched(string id, byte[] data)
 {
     _serverSokcet.Send(id, data);
 }
Example #7
0
        public void Start(IServerSocket socket)
        {
            var conf = File.ReadAllText("modules.conf");

            socket.Send(conf);
        }