public void OnDisconnect(MobaClient client) { //每次下线的时候 要通知好友 显示离线状态 #region 每次下线的时候 要通知好友 显示离线状态 PlayerModel model = playerCache.GetModel(client); if (model != null) { MobaClient tempClient = null; string[] friends = model.FriendIdList.Split(','); foreach (string item in friends) { if (string.IsNullOrEmpty(item)) { continue; } int id = int.Parse(item); if (!playerCache.isOnline(id)) { continue; } tempClient = playerCache.GetClient(id); Send(tempClient, OpCode.PlayerCode, OpPlayer.FriendOffline, 0, "此玩家已下线", model.Id); } } #endregion matchCache.Offline(client, playerCache.GetId(client)); playerCache.Offline(client); }
public void OnDisconnect(MobaClient client) { //每次下线的时候要通知好友显示离线状态 PlayerModel model = playerCache.GetModel(client); if (model != null) { string[] friends = model.FriendIdList.Split(','); foreach (string item in friends) { if (item.Equals("")) { continue; } int itemId = int.Parse(item); if (!playerCache.IsOnLine(itemId)) { continue; } MobaClient tempClient = playerCache.GetClient(itemId); Send(tempClient, OpCode.PlayerCode, OpPlayer.FriendOffLine, 0, "此玩家下线", model.Id); } matchCache.OffLine(client, playerCache.GetId(client)); playerCache.OffLine(client); } }
/// <summary> /// 聊天 /// </summary> /// <param name="client"></param> /// <param name="v"></param> private void onTalk(MobaClient client, string text) { //给当前客户端所在的房间内所有人发一条消息 :text PlayerModel player = playerCache.GetModel(client); if (player == null) { return; } SelectRoom room = selectCache.GetRoom(player.Id); //角色名:我要选这个 string str = string.Format("{0}:{1}", player.Name, text); room.Brocast(OpCode.SelectCode, OpSelect.Talk, 0, "有玩家发言了", null, str); }
/// <summary> /// 聊天,给房间所有人发聊天信息 /// </summary> /// <param name="client"></param> /// <param name="text"></param> private void onTalk(MobaClient client, string text) { //服务器输出到日志文件的日志 //MobaApplication.LogInfo(text); //给当前客户端所在的房间内所有人发一条消息 PlayerModel player = playerCache.GetModel(client); if (player == null) { return; } SelectRoom room = selectCache.GetRoom(player.Id); //角色名:说了什么 string str = string.Format("{0} : {1}", player.Name, text); room.Brocast(OpCode.SelectCode, OpSelect.Talk, 0, "有玩家发言了", null, str); }
private void OnTalk(MobaClient client, string context) { //给房间内的当前客户端所有人发一条消息:context PlayerModel player = playerCache.GetModel(client); if (player == null) { return; } SelectRoom room = selectCache.GetRoom(player.Id); if (room == null) { return; } string str = string.Format("{0} : {1}", player.Name, context); room.Brocast(OpCode.SelectCode, OpSelect.Talk, 0, "有玩家发言了", null, str); }