public static void SendMessage(Session sender, string recipient, string message) { List <Session> recipientSessions = NetworkManager.FindSession(recipient).ToList(); if (recipientSessions.Count == 0) { var conversationError = new NetworkObject(); conversationError.AddField(0, NetworkObjectField.CreateIntField((int)ConversationAction.NotOnline)); conversationError.AddField(1, NetworkObjectField.CreateStringField(recipient)); sender.EnqueueMessage(ObjectOpcode.Conversation, conversationError); return; } foreach (Session session in recipientSessions) { var receiveTell = new NetworkObject(); receiveTell.AddField(0, NetworkObjectField.CreateIntField((int)ConversationAction.ReceiveTell)); receiveTell.AddField(1, NetworkObjectField.CreateStringField(sender.Account.Username)); receiveTell.AddField(2, NetworkObjectField.CreateStringField(message)); session.EnqueueMessage(ObjectOpcode.Conversation, receiveTell); } List <Session> senderSessions = NetworkManager.FindSession(sender.Account.Username).ToList(); foreach (Session session in senderSessions) { var sendTell = new NetworkObject(); sendTell.AddField(0, NetworkObjectField.CreateIntField((int)ConversationAction.SendTell)); sendTell.AddField(1, NetworkObjectField.CreateStringField(recipient)); sendTell.AddField(2, NetworkObjectField.CreateStringField(message)); session.EnqueueMessage(ObjectOpcode.Conversation, sendTell); } }
public override NetworkObject ToNetworkObject() { NetworkObject class2 = new NetworkObject(); class2.AddField(0, NetworkObjectField.CreateStringField(this.string_0)); return(class2); }
/// <summary> /// /// </summary> private void AddAccount(string account) { if (friendList.ContainsKey(account)) { return; } friendList.Add(account, new List <CharacterObject>()); IEnumerable <Session> sessions = NetworkManager.FindSession(account); foreach (Session session in sessions) { friendList[account].Add(session.Character); NetworkObject characterAdd = new NetworkObject(); characterAdd.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.Add)); characterAdd.AddField(1, NetworkObjectField.CreateStringField(account)); characterAdd.AddField(2, NetworkObjectField.CreateBoolField(true)); characterAdd.AddField(3, NetworkObjectField.CreateObjectField(session.Character.ToNetworkObject())); owner.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.FriendList, characterAdd, false)); } if (friendList[account].Count == 0) { NetworkObject accountAdd = new NetworkObject(); accountAdd.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.Add)); accountAdd.AddField(1, NetworkObjectField.CreateStringField(account)); accountAdd.AddField(2, NetworkObjectField.CreateBoolField(false)); owner.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.FriendList, accountAdd, false)); } }
public override NetworkObject ToNetworkObject() { var fellowship = new NetworkObject(); fellowship.AddField(0, NetworkObjectField.CreateStringField(Name)); fellowship.AddField(1, NetworkObjectField.CreateIntField((int)Unknown1)); return(fellowship); }
public override NetworkObject ToNetworkObject() { NetworkObject networkObject = new NetworkObject(); networkObject.AddField(0, NetworkObjectField.CreateStringField(Server)); networkObject.AddField(1, NetworkObjectField.CreateStringField(Name)); networkObject.AddField(2, NetworkObjectField.CreateIntField((int)Guid)); networkObject.AddField(3, NetworkObjectField.CreateLongField(Sequence)); networkObject.AddField(4, NetworkObjectField.CreateStringField(Unknown1)); return(networkObject); }
/// <summary> /// /// </summary> public override void RemoveMember(Session member) { base.AddMember(member); member.Channels.Remove(this); var channelLeave = new NetworkObject(); channelLeave.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Leave)); channelLeave.AddField(1, NetworkObjectField.CreateStringField(name)); channelLeave.AddField(2, NetworkObjectField.CreateStringField(GetShortcut())); member.EnqueueMessage(ObjectOpcode.Channel, channelLeave); }
/// <summary> /// /// </summary> public override void AddMember(Session member) { base.AddMember(member); member.Channels.Add(this); var channelJoin = new NetworkObject(); channelJoin.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Join)); channelJoin.AddField(1, NetworkObjectField.CreateStringField(name)); channelJoin.AddField(2, NetworkObjectField.CreateStringField(GetShortcut())); member.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.Channel, channelJoin, false)); }
/// <summary> /// /// </summary> public void RemoveAccount(string account) { if (!friendList.ContainsKey(account)) { return; } friendList.Remove(account); NetworkObject networkObject = new NetworkObject(); networkObject.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.Remove)); networkObject.AddField(1, NetworkObjectField.CreateStringField(account)); owner.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.FriendList, networkObject, false)); }
/// <summary> /// /// </summary> public void CharacterSignOut(string account, CharacterObject character) { if (!friendList.ContainsKey(account)) { return; } friendList[account].Remove(character); NetworkObject characterSignOut = new NetworkObject(); characterSignOut.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.SignOut)); characterSignOut.AddField(1, NetworkObjectField.CreateStringField(account)); characterSignOut.AddField(2, NetworkObjectField.CreateObjectField(character.ToNetworkObject())); owner.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.FriendList, characterSignOut, false)); }
/// <summary> /// Broadcast text message from <see cref="CharacterObject"/> to all members. /// </summary> public void BroadcastMessage(CharacterObject character, string message) { if (!HasMember(character)) { return; } var channelMessage = new NetworkObject(); channelMessage.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Message)); channelMessage.AddField(1, NetworkObjectField.CreateObjectField(character.ToNetworkObject())); channelMessage.AddField(2, NetworkObjectField.CreateStringField(name)); channelMessage.AddField(3, NetworkObjectField.CreateStringField(message)); channelMessage.AddField(4, NetworkObjectField.CreateStringField(GetShortcut())); BroadcastMessage(ObjectOpcode.Channel, channelMessage); }
/// <summary> /// /// </summary> public void CharacterSignIn(string account, CharacterObject character) { if (!friendList.ContainsKey(account)) { return; } friendList[account].Add(character); NetworkObject characterSignIn = new NetworkObject(); characterSignIn.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.SignIn)); characterSignIn.AddField(1, NetworkObjectField.CreateStringField(account)); characterSignIn.AddField(2, NetworkObjectField.CreateObjectField(character.ToNetworkObject())); owner.EnqueueMessage(ObjectOpcode.FriendList, characterSignIn); }
protected override void OnRemoveMember(CharacterObject character) { Session session = NetworkManager.FindSessionByCharacter(character); if (session != null) { session.Channels.Remove(this); var channelLeave = new NetworkObject(); channelLeave.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Leave)); channelLeave.AddField(1, NetworkObjectField.CreateStringField(name)); channelLeave.AddField(2, NetworkObjectField.CreateStringField(GetShortcut())); session.EnqueueMessage(ObjectOpcode.Channel, channelLeave); } members.Remove(character.Sequence); }
/// <summary> /// /// </summary> public void BroadcastMessage(Session member, string message) { if (!HasMember(member.Character)) { return; } DatabaseManager.Database.LogConversation(name, member.Account.Username, message, member.Remote.Address.ToString()); var channelMessage = new NetworkObject(); channelMessage.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Message)); channelMessage.AddField(1, NetworkObjectField.CreateObjectField(member.Character.ToNetworkObject())); channelMessage.AddField(2, NetworkObjectField.CreateStringField(name)); channelMessage.AddField(3, NetworkObjectField.CreateStringField(message)); channelMessage.AddField(4, NetworkObjectField.CreateStringField(GetShortcut())); BroadcastMessage(new ServerObjectPacket(ObjectOpcode.Channel, channelMessage, false)); }
protected override void OnAddMember(CharacterObject character) { Session session = NetworkManager.FindSessionByCharacter(character); if (session == null) { return; } session.Channels.Add(this); var channelJoin = new NetworkObject(); channelJoin.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Join)); channelJoin.AddField(1, NetworkObjectField.CreateStringField(name)); channelJoin.AddField(2, NetworkObjectField.CreateStringField(GetShortcut())); session.EnqueueMessage(ObjectOpcode.Channel, channelJoin); members.Add(character.Sequence, character); }
public static void SendMessage(Session sender, string recipient, string message) { List <Session> recipientSessions = NetworkManager.FindSession(recipient).ToList(); if (recipientSessions.Count == 0) { var conversationError = new NetworkObject(); conversationError.AddField(0, NetworkObjectField.CreateIntField((int)ConversationAction.NotOnline)); conversationError.AddField(1, NetworkObjectField.CreateStringField(recipient)); sender.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.Conversation, conversationError, false)); return; } foreach (Session session in recipientSessions) { var receiveTell = new NetworkObject(); receiveTell.AddField(0, NetworkObjectField.CreateIntField((int)ConversationAction.ReceiveTell)); receiveTell.AddField(1, NetworkObjectField.CreateStringField(sender.Account.Username)); receiveTell.AddField(2, NetworkObjectField.CreateStringField(message)); session.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.Conversation, receiveTell, false)); } List <Session> senderSessions = NetworkManager.FindSession(sender.Account.Username).ToList(); foreach (Session session in senderSessions) { var sendTell = new NetworkObject(); sendTell.AddField(0, NetworkObjectField.CreateIntField((int)ConversationAction.SendTell)); sendTell.AddField(1, NetworkObjectField.CreateStringField(recipient)); sendTell.AddField(2, NetworkObjectField.CreateStringField(message)); session.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.Conversation, sendTell, false)); } if (!sender.Account.Username.Equals(recipient, StringComparison.InvariantCultureIgnoreCase)) { DatabaseManager.Database.LogConversation(sender.Account.Username, recipient, message, sender.Remote.Address.ToString(), recipientSessions[0].Remote.Address.ToString()); } }