|
板凳
楼主 |
发表于 2016-8-19 09:49:27
|
只看该作者
离开房间是:
private void OnUserLeaveRoomActionCallBack(int userId, int roomId, int userValue)
{
//如果是客户端,客户端置进入房间信息,记录日志
ReceptionClient client = GetClientById(userId);
int a = _lstClient.Count;
if (client != null)
{
this.Dispatcher.Invoke(new Action(() =>
{
client.RoomID = 0;
client.RoomName = string.Empty;
}));
}
//如果是坐席端,置房间状态,并广播给用户房间状态
ReceptionRoom room = GetRoomById(roomId);
//byte[] sendCmd = receptionDataCmd.CreateCmdRoomStatus(room);
if (room.RoomDoctorID == userId)
{
this.Dispatcher.Invoke(new Action(() =>
{
//置空
room.RoomDoctorID = 0;
room.RoomDoctorName = string.Empty;
byte[] sendCmd = receptionDataCmd.CreateCmdRoomStatus(room);
foreach (var o in _lstClient)
{
//向所有用户发送房间更新操作
AnyChatServerSDK.BRAS_TransBuffer(o.UserID, sendCmd, sendCmd.Length);
}
AnyChatServerSDK.BRAS_TransBuffer(userId, sendCmd, sendCmd.Length);
}));
}
else if (room.UserID == userId)
{
room.UserID = 0;
byte[] sendCmd = receptionDataCmd.CreateCmdRoomStatus(room);
foreach (var o in _lstClient)
{
//向所有用户发送房间更新操作
AnyChatServerSDK.BRAS_TransBuffer(o.UserID, sendCmd, sendCmd.Length);
}
}
}
进入房间的:
private void OnUserEnterRoomActionCallBack(int userId, int roomId, int userValue)
{
//如果是坐席端,置房间状态,并广播给用户房间状态
ReceptionRoom room = GetRoomById(roomId);//当前房间
if (room.RoomDoctorID != userId)
{
room.UserID = userId;
}
byte[] sendCmd = receptionDataCmd.CreateCmdRoomStatus(room);
foreach (var o in _lstClient)//其他在线用户
{
//向所有用户发送房间更新操作
AnyChatServerSDK.BRAS_TransBuffer(o.UserID, sendCmd, sendCmd.Length);
}
foreach (var v in _lstRoom)//所有用户
{
if (v.RoomDoctorID != 0)
{
AnyChatServerSDK.BRAS_TransBuffer(v.RoomDoctorID, sendCmd, sendCmd.Length);
}
}
}
已经记录了的,并且已经返回所有房间的状态了 |
|