Merge pull request #42 from Makinolo/main
Allows sending messages only to a group of users
This commit is contained in:
commit
d1b0082768
@ -266,10 +266,10 @@ namespace CoopClient
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enable or disable the local traffic for this player
|
/// Enable or disable the local traffic for this player
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stop"></param>
|
/// <param name="enable"></param>
|
||||||
public static void SetLocalTraffic(bool stop)
|
public static void SetLocalTraffic(bool enable)
|
||||||
{
|
{
|
||||||
Main.DisableTraffic = stop;
|
Main.DisableTraffic = !enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -67,7 +67,9 @@ namespace CoopClient
|
|||||||
|
|
||||||
MainSettings = Util.ReadSettings();
|
MainSettings = Util.ReadSettings();
|
||||||
MainNetworking = new Networking();
|
MainNetworking = new Networking();
|
||||||
|
#if !NON_INTERACTIVE
|
||||||
MainMenu = new MenusMain();
|
MainMenu = new MenusMain();
|
||||||
|
#endif
|
||||||
MainChat = new Chat();
|
MainChat = new Chat();
|
||||||
Players = new Dictionary<long, EntitiesPlayer>();
|
Players = new Dictionary<long, EntitiesPlayer>();
|
||||||
NPCs = new Dictionary<long, EntitiesNpc>();
|
NPCs = new Dictionary<long, EntitiesNpc>();
|
||||||
|
@ -105,11 +105,11 @@ namespace CoopClient.Menus.Sub
|
|||||||
MainMenu.Visible = false;
|
MainMenu.Visible = false;
|
||||||
|
|
||||||
Main.MainNetworking.DisConnectFromServer(address);
|
Main.MainNetworking.DisConnectFromServer(address);
|
||||||
|
#if !NON_INTERACTIVE
|
||||||
Main.MainMenu.ServerIpItem.AltTitle = address;
|
Main.MainMenu.ServerIpItem.AltTitle = address;
|
||||||
|
|
||||||
Main.MainMenu.MainMenu.Visible = true;
|
Main.MainMenu.MainMenu.Visible = true;
|
||||||
|
#endif
|
||||||
Main.MainSettings.LastServerAddress = address;
|
Main.MainSettings.LastServerAddress = address;
|
||||||
Util.SaveSettings();
|
Util.SaveSettings();
|
||||||
}
|
}
|
||||||
|
@ -166,9 +166,10 @@ namespace CoopServer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logging.Info("Loading resource...");
|
string resourcepath = AppDomain.CurrentDomain.BaseDirectory + "resources" + Path.DirectorySeparatorChar + MainSettings.Resource + ".dll";
|
||||||
|
Logging.Info($"Loading resource {resourcepath}...");
|
||||||
|
|
||||||
Assembly asm = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "resources" + Path.DirectorySeparatorChar + MainSettings.Resource + ".dll");
|
Assembly asm = Assembly.LoadFrom(resourcepath);
|
||||||
Type[] types = asm.GetExportedTypes();
|
Type[] types = asm.GetExportedTypes();
|
||||||
IEnumerable<Type> validTypes = types.Where(t => !t.IsInterface && !t.IsAbstract).Where(t => typeof(ServerScript).IsAssignableFrom(t));
|
IEnumerable<Type> validTypes = types.Where(t => !t.IsInterface && !t.IsAbstract).Where(t => typeof(ServerScript).IsAssignableFrom(t));
|
||||||
Type[] enumerable = validTypes as Type[] ?? validTypes.ToArray();
|
Type[] enumerable = validTypes as Type[] ?? validTypes.ToArray();
|
||||||
|
@ -207,10 +207,19 @@ namespace CoopServer
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region FUNCTIONS
|
#region FUNCTIONS
|
||||||
public static void SendModPacketToAll(string mod, byte customID, byte[] bytes)
|
public static void SendModPacketToAll(string mod, byte customID, byte[] bytes, List<long> netHandleList = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
List<NetConnection> connections;
|
||||||
|
if (netHandleList == null)
|
||||||
|
{
|
||||||
|
connections = Server.MainNetServer.Connections;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connections = Server.MainNetServer.Connections.FindAll(c => netHandleList.Contains(c.RemoteUniqueIdentifier));
|
||||||
|
}
|
||||||
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
||||||
new ModPacket()
|
new ModPacket()
|
||||||
{
|
{
|
||||||
@ -220,7 +229,7 @@ namespace CoopServer
|
|||||||
CustomPacketID = customID,
|
CustomPacketID = customID,
|
||||||
Bytes = bytes
|
Bytes = bytes
|
||||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||||
Server.MainNetServer.SendMessage(outgoingMessage, Server.MainNetServer.Connections, NetDeliveryMethod.ReliableOrdered, (int)ConnectionChannel.Mod);
|
Server.MainNetServer.SendMessage(outgoingMessage, connections, NetDeliveryMethod.ReliableOrdered, (int)ConnectionChannel.Mod);
|
||||||
Server.MainNetServer.FlushSendQueue();
|
Server.MainNetServer.FlushSendQueue();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -285,7 +294,7 @@ namespace CoopServer
|
|||||||
return Server.Clients.Find(x => x.Player.Username.ToLower() == username.ToLower());
|
return Server.Clients.Find(x => x.Player.Username.ToLower() == username.ToLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendChatMessageToAll(string message, string username = "Server")
|
public static void SendChatMessageToAll(string message, string username = "Server", List<long> netHandleList = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -294,13 +303,22 @@ namespace CoopServer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<NetConnection> connections;
|
||||||
|
if (netHandleList == null)
|
||||||
|
{
|
||||||
|
connections = Server.MainNetServer.Connections;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connections = Server.MainNetServer.Connections.FindAll(c => netHandleList.Contains(c.RemoteUniqueIdentifier));
|
||||||
|
}
|
||||||
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
||||||
new ChatMessagePacket()
|
new ChatMessagePacket()
|
||||||
{
|
{
|
||||||
Username = username,
|
Username = username,
|
||||||
Message = message
|
Message = message
|
||||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||||
Server.MainNetServer.SendMessage(outgoingMessage, Server.MainNetServer.Connections, NetDeliveryMethod.ReliableOrdered, (int)ConnectionChannel.Chat);
|
Server.MainNetServer.SendMessage(outgoingMessage, connections, NetDeliveryMethod.ReliableOrdered, (int)ConnectionChannel.Chat);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user