本文整理汇总了C#中DarkMultiPlayerCommon.ServerMessage类的典型用法代码示例。如果您正苦于以下问题:C# ServerMessage类的具体用法?C# ServerMessage怎么用?C# ServerMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerMessage类属于DarkMultiPlayerCommon命名空间,在下文中一共展示了ServerMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HandleVesselRemoval
public static void HandleVesselRemoval(ClientObject client, byte[] messageData)
{
using (MessageReader mr = new MessageReader(messageData))
{
//Don't care about the subspace on the server.
mr.Read<double>();
string vesselID = mr.Read<string>();
bool isDockingUpdate = mr.Read<bool>();
if (!isDockingUpdate)
{
DarkLog.Debug("Removing vessel " + vesselID + " from " + client.playerName);
}
else
{
DarkLog.Debug("Removing DOCKED vessel " + vesselID + " from " + client.playerName);
}
if (File.Exists(Path.Combine(Server.universeDirectory, "Vessels", vesselID + ".txt")))
{
lock (Server.universeSizeLock)
{
File.Delete(Path.Combine(Server.universeDirectory, "Vessels", vesselID + ".txt"));
}
}
//Relay the message.
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.VESSEL_REMOVE;
newMessage.data = messageData;
ClientHandler.SendToAll(client, newMessage, false);
}
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:30,代码来源:VesselRemove.cs
示例2: HandlePlayerColor
public static void HandlePlayerColor(ClientObject client, byte[] messageData)
{
using (MessageReader mr = new MessageReader(messageData))
{
PlayerColorMessageType messageType = (PlayerColorMessageType)mr.Read<int>();
switch (messageType)
{
case PlayerColorMessageType.SET:
{
string playerName = mr.Read<string>();
if (playerName != client.playerName)
{
DarkLog.Debug(client.playerName + " tried to send a color update for " + playerName + ", kicking.");
Messages.ConnectionEnd.SendConnectionEnd(client, "Kicked for sending a color update for another player");
return;
}
client.playerColor = mr.Read<float[]>();
//Relay the message
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.PLAYER_COLOR;
newMessage.data = messageData;
ClientHandler.SendToAll(client, newMessage, true);
}
break;
}
}
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:27,代码来源:PlayerColor.cs
示例3: SendScenarioModules
public static void SendScenarioModules(ClientObject client)
{
int numberOfScenarioModules = Directory.GetFiles(Path.Combine(Server.universeDirectory, "Scenarios", client.playerName)).Length;
int currentScenarioModule = 0;
string[] scenarioNames = new string[numberOfScenarioModules];
byte[][] scenarioDataArray = new byte[numberOfScenarioModules][];
foreach (string file in Directory.GetFiles(Path.Combine(Server.universeDirectory, "Scenarios", client.playerName)))
{
//Remove the .txt part for the name
scenarioNames[currentScenarioModule] = Path.GetFileNameWithoutExtension(file);
scenarioDataArray[currentScenarioModule] = File.ReadAllBytes(file);
currentScenarioModule++;
}
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.SCENARIO_DATA;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<string[]>(scenarioNames);
foreach (byte[] scenarioData in scenarioDataArray)
{
if (client.compressionEnabled)
{
mw.Write<byte[]>(Compression.CompressIfNeeded(scenarioData));
}
else
{
mw.Write<byte[]>(Compression.AddCompressionHeader(scenarioData, false));
}
}
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:33,代码来源:ScenarioData.cs
示例4: SendAllPlayerColors
public static void SendAllPlayerColors(ClientObject client)
{
Dictionary<string,float[]> sendColors = new Dictionary<string, float[]>();
foreach (ClientObject otherClient in ClientHandler.GetClients())
{
if (otherClient.authenticated && otherClient.playerColor != null)
{
if (otherClient != client)
{
sendColors[otherClient.playerName] = otherClient.playerColor;
}
}
}
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.PLAYER_COLOR;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<int>((int)PlayerColorMessageType.LIST);
mw.Write<int>(sendColors.Count);
foreach (KeyValuePair<string, float[]> kvp in sendColors)
{
mw.Write<string>(kvp.Key);
mw.Write<float[]>(kvp.Value);
}
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:28,代码来源:PlayerColor.cs
示例5: HandlePingRequest
public static void HandlePingRequest(ClientObject client, byte[] messageData)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.PING_REPLY;
newMessage.data = messageData;
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:7,代码来源:PingRequest.cs
示例6: RunNukeKSC
public static void RunNukeKSC(string commandText)
{
lock (Server.universeSizeLock)
{
string[] vesselList = Directory.GetFiles(Path.Combine(Server.universeDirectory, "Vessels"));
int numberOfRemovals = 0;
foreach (string vesselFile in vesselList)
{
string vesselID = Path.GetFileNameWithoutExtension(vesselFile);
bool landedAtKSC = false;
bool landedAtRunway = false;
using (StreamReader sr = new StreamReader(vesselFile))
{
string currentLine = sr.ReadLine();
while (currentLine != null && !landedAtKSC && !landedAtRunway)
{
string trimmedLine = currentLine.Trim();
if (trimmedLine.StartsWith("landedAt = "))
{
string landedAt = trimmedLine.Substring(trimmedLine.IndexOf("=") + 2);
if (landedAt == "KSC")
{
landedAtKSC = true;
}
if (landedAt == "Runway")
{
landedAtRunway = true;
}
}
currentLine = sr.ReadLine();
}
}
if (landedAtKSC | landedAtRunway)
{
DarkLog.Normal("Removing vessel: " + vesselID);
//Delete it from the universe
if (File.Exists(vesselFile))
{
File.Delete(vesselFile);
}
//Send a vessel remove message
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.VESSEL_REMOVE;
using (MessageWriter mw = new MessageWriter())
{
//Send it with a delete time of 0 so it shows up for all players.
mw.Write<int>(0);
mw.Write<double>(0);
mw.Write<string>(vesselID);
mw.Write<bool>(false);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToAll(null, newMessage, false);
numberOfRemovals++;
}
}
DarkLog.Normal("Nuked " + numberOfRemovals + " vessels around the KSC");
}
}
开发者ID:martindevans,项目名称:DarkMultiPlayer,代码行数:59,代码来源:NukeKSC.cs
示例7: SendKerbalsComplete
private static void SendKerbalsComplete(ClientObject client)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.KERBAL_COMPLETE;
ClientHandler.SendToClient(client, newMessage, false);
//Send vessel list needed for sync to the client
VesselRequest.SendVesselList(client);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:8,代码来源:KerbalsRequest.cs
示例8: HandleVesselUpdate
public static void HandleVesselUpdate(ClientObject client, byte[] messageData)
{
//We only relay this message.
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.VESSEL_UPDATE;
newMessage.data = messageData;
ClientHandler.SendToAll(client, newMessage, false);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:8,代码来源:VesselUpdate.cs
示例9: SendConnectionEnd
public static void SendConnectionEnd(ClientObject client, string reason)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.CONNECTION_END;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<string>(reason);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:11,代码来源:ConnectionEnd.cs
示例10: SendDMPModMessageToAll
public static void SendDMPModMessageToAll(ClientObject excludeClient, string modName, byte[] messageData, bool highPriority)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.MOD_DATA;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<string>(modName);
mw.Write<byte[]>(messageData);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToAll(excludeClient, newMessage, highPriority);
}
开发者ID:nux17,项目名称:DarkMultiPlayer,代码行数:12,代码来源:DMPModInterface.cs
示例11: SendConsoleMessageToClient
public static void SendConsoleMessageToClient(ClientObject client, string message)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.CHAT_MESSAGE;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<int>((int)ChatMessageType.CONSOLE_MESSAGE);
mw.Write<string>(message);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, false);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:12,代码来源:Chat.cs
示例12: SendAllAdmins
public static void SendAllAdmins(ClientObject client)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.ADMIN_SYSTEM;
using (MessageWriter mw = new MessageWriter())
{
mw.Write((int)AdminMessageType.LIST);
mw.Write<string[]>(DarkMultiPlayerServer.AdminSystem.fetch.GetAdmins());
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:12,代码来源:AdminSystemMessage.cs
示例13: SendChatMessageToClient
public static void SendChatMessageToClient(ClientObject client, string messageText)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.CHAT_MESSAGE;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<int>((int)ChatMessageType.PRIVATE_MESSAGE);
mw.Write<string>(Settings.settingsStore.consoleIdentifier);
mw.Write<string>(client.playerName);
mw.Write(messageText);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:14,代码来源:Chat.cs
示例14: SendHandshakeChallange
public static void SendHandshakeChallange(ClientObject client)
{
client.challange = new byte[1024];
Random rand = new Random();
rand.NextBytes(client.challange);
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.HANDSHAKE_CHALLANGE;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<byte[]>(client.challange);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:14,代码来源:Handshake.cs
示例15: SendKerbal
private static void SendKerbal(ClientObject client, string kerbalName, byte[] kerbalData)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.KERBAL_REPLY;
using (MessageWriter mw = new MessageWriter())
{
//Send the vessel with a send time of 0 so it instantly loads on the client.
mw.Write<double>(0);
mw.Write<string>(kerbalName);
mw.Write<byte[]>(kerbalData);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, false);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:14,代码来源:KerbalsRequest.cs
示例16: SendChatMessageToChannel
public static void SendChatMessageToChannel(string channel, string messageText)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.CHAT_MESSAGE;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<int>((int)ChatMessageType.CHANNEL_MESSAGE);
mw.Write<string>(Settings.settingsStore.consoleIdentifier);
// Channel
mw.Write<string>(channel);
mw.Write(messageText);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToAll(null, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:15,代码来源:Chat.cs
示例17: SendChatMessageToAll
public static void SendChatMessageToAll(string messageText)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.CHAT_MESSAGE;
using (MessageWriter mw = new MessageWriter())
{
mw.Write<int>((int)ChatMessageType.CHANNEL_MESSAGE);
mw.Write<string>("Server");
//Global channel
mw.Write<string>("");
mw.Write(messageText);
newMessage.data = mw.GetMessageBytes();
}
SendToAll(null, newMessage, true);
}
开发者ID:Norgg,项目名称:DarkMultiPlayer,代码行数:15,代码来源:ClientHandler.cs
示例18: SendMotdReply
private static void SendMotdReply(ClientObject client)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.MOTD_REPLY;
string newMotd = Settings.settingsStore.serverMotd;
newMotd = newMotd.Replace("%name%", client.playerName);
newMotd = newMotd.Replace(@"\n", Environment.NewLine);
using (MessageWriter mw = new MessageWriter())
{
mw.Write<string>(newMotd);
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:16,代码来源:MotdRequest.cs
示例19: HandleSyncTimeRequest
public static void HandleSyncTimeRequest(ClientObject client, byte[] messageData)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.SYNC_TIME_REPLY;
using (MessageWriter mw = new MessageWriter())
{
using (MessageReader mr = new MessageReader(messageData))
{
//Client send time
mw.Write<long>(mr.Read<long>());
//Server receive time
mw.Write<long>(DateTime.UtcNow.Ticks);
newMessage.data = mw.GetMessageBytes();
}
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:17,代码来源:SyncTimeRequest.cs
示例20: SendAllLocks
public static void SendAllLocks(ClientObject client)
{
ServerMessage newMessage = new ServerMessage();
newMessage.type = ServerMessageType.LOCK_SYSTEM;
//Send the dictionary as 2 string[]'s.
Dictionary<string,string> lockList = DarkMultiPlayerServer.LockSystem.fetch.GetLockList();
List<string> lockKeys = new List<string>(lockList.Keys);
List<string> lockValues = new List<string>(lockList.Values);
using (MessageWriter mw = new MessageWriter())
{
mw.Write((int)LockMessageType.LIST);
mw.Write<string[]>(lockKeys.ToArray());
mw.Write<string[]>(lockValues.ToArray());
newMessage.data = mw.GetMessageBytes();
}
ClientHandler.SendToClient(client, newMessage, true);
}
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:17,代码来源:LockSystem.cs
注:本文中的DarkMultiPlayerCommon.ServerMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论