private void callbackSendMessage(WindowChat.TypeChat rangeType, int rangeId, string message) { if (message.Length > 0) { Data.ChatInfo c = new Data.ChatInfo(); c.FromId = userId; c.Name = windowEntryName.userName; c.Message = message; c.RangeType = (int)rangeType; switch (rangeType) { case WindowChat.TypeChat.World: c.RangeId = -1; break; case WindowChat.TypeChat.Group: c.RangeId = windowEntryName.groupId; break; case WindowChat.TypeChat.Private: c.RangeId = rangeId; break; } var result = makeData(1, c); sock.Send(result); } }
private void receiveChat(byte[] data) { ObjectPacker unpack = new ObjectPacker(); Data.ChatInfo info = unpack.Unpack <Data.ChatInfo>(data); windowChat.SetMessage(info, userId); }
public void SetMessage(Data.ChatInfo info, int myUserId) { switch ((TypeChat)info.RangeType) { case TypeChat.World: case TypeChat.Group: chatControllers[info.RangeType].UpdateMessageList(info.Name, info.Message); break; case TypeChat.Private: ChatControllerPrivate ccp = (ChatControllerPrivate)chatControllers[info.RangeType]; if (info.FromId == myUserId) { ccp.UpdateMessageList(info.RangeId, info.Name, info.Message, (curUserId == info.RangeId)); } else { ccp.UpdateMessageList(info.FromId, info.Name, info.Message, (curUserId == info.FromId)); } // todo break; default: Debug.LogError("unkwoun type!! " + info.RangeType); break; } if (!chatControllers[info.RangeType].isDispEnable) { imageNotices[info.RangeType].SetActive(true); } }