public static void LeaveMessenger(int cid) { Character chr = CenterServer.Instance.FindCharacter(cid); Messenger messenger = chr.Messenger; if (messenger == null) { return; } byte slot = chr.MessengerSlot; bool empty = true; foreach (Character mChr in messenger.Users) { if (mChr != null) { if (mChr.ID != chr.ID) { empty = false; } mChr.SendPacket(MessengerPacket.Leave(slot)); } } messenger.Users[slot] = null; chr.Messenger = null; chr.MessengerSlot = 0; if (empty) { Messengers.Remove(messenger); } }
private static void JoinExistingMessenger(int messengerID, Character chr) { Messenger messenger = Messengers.First(m => m.ID == messengerID); if (messenger == null) // This should already be confirmed when joining, but just to make sure. { return; } if (messenger.AddPlayer(chr)) // No action if messenger is full afaik. { chr.Messenger = messenger; foreach (Character mChr in messenger.Users) { if (mChr == null) { continue; } if (mChr.ID == chr.ID) { chr.SendPacket(MessengerPacket.Enter(chr.MessengerSlot)); } else { chr.SendPacket(MessengerPacket.SelfEnter(mChr)); // Announce existing players to joinee mChr.SendPacket(MessengerPacket.SelfEnter(chr)); // Announce joinee to existing players } } } }
protected override void Register() { MessageServer.Clients.Add(this); this.SessionID = Randomizer.NextLong(); MessengerPacket.GameLog(this, this.CharacterID); this.CharacterID++; Log.Inform("Accepted connection from {0}.", this.Title); }
public static void OnAvatar(Packet packet) { Character chr = ParseMessengerCharacter(packet); //, chr, false); Messenger messenger = chr.Messenger; foreach (var c in messenger.Users) { c.SendPacket(MessengerPacket.Avatar(chr)); } }
public static void Chat(int cid, String message) { Character chr = CenterServer.Instance.FindCharacter(cid); if (chr.Messenger == null) { return; } foreach (Character mChr in chr.Messenger.Users) { if (mChr != null && mChr.ID != cid) { mChr.SendPacket(MessengerPacket.Chat(message)); } } }
public static void SendInvite(int senderID, String recipientName) { Character recipient = CenterServer.Instance.FindCharacter(recipientName); Character sender = CenterServer.Instance.FindCharacter(senderID); Messenger messenger = sender.Messenger; if (sender == null || messenger == null || messenger.usersInChat() >= MAX_USERS) { return; } else if (recipient != null) { recipient.SendPacket(MessengerPacket.Invite(sender.Name, messenger.ID)); } sender.SendPacket(MessengerPacket.InviteResult(recipientName, recipient != null)); }
private static void CreateMessenger(Character pOwner) { Messenger messenger = new Messenger(pOwner); pOwner.SendPacket(MessengerPacket.Enter(pOwner.MessengerSlot)); }