当前位置: 首页>>代码示例>>C#>>正文


C# DarkMultiPlayerCommon.ClientMessage类代码示例

本文整理汇总了C#中DarkMultiPlayerCommon.ClientMessage的典型用法代码示例。如果您正苦于以下问题:C# ClientMessage类的具体用法?C# ClientMessage怎么用?C# ClientMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClientMessage类属于DarkMultiPlayerCommon命名空间,在下文中一共展示了ClientMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnMessageReceived

        public override void OnMessageReceived(ClientObject client, ClientMessage message)
        {
            if (!client.authenticated)
            {
                //Only handle authenticated messages
                return;
            }

            if (message.type == ClientMessageType.SCENARIO_DATA)
            {
                HandleScenarioMessage(client, message);
                message.handled = true;
            }
        }
开发者ID:JoshBlake,项目名称:DMPSharedScience,代码行数:14,代码来源:SharedSciencePlugin.cs

示例2: OnMessageReceived

 public void OnMessageReceived(ClientObject client, ClientMessage message)
 {
     if (message.type == ClientMessageType.CHAT_MESSAGE)
     {
         using (MessageReader mr = new MessageReader(message.data, false))
         {
             ChatMessageType messageType = (ChatMessageType)mr.Read<int>();
             string fromPlayer = mr.Read<string>();
             if (messageType == ChatMessageType.CHANNEL_MESSAGE)
             {
                 string channel = mr.Read<string>();
                 string umessage = mr.Read<string>();
                 ircClient.Channels["#" + channel].SendMessage(String.Format("{0} -> {1}", fromPlayer, umessage));
             }
         }
     }
 }
开发者ID:JoshBlake,项目名称:DarkChat,代码行数:17,代码来源:DarkChat.cs

示例3: FireOnMessageReceived

        //Fire OnMessageReceived
        public static void FireOnMessageReceived(ClientObject client, ClientMessage message)
        {
            bool handledByAny = false;
            foreach (var plugin in loadedPlugins)
            {
                try
                {
                    plugin.OnMessageReceived(client, message);

                    //prevent plugins from unhandling other plugin's handled requests
                    if (message.handled)
                    {
                        handledByAny = true;
                    }
                }
                catch (Exception e)
                {
                    Type type = plugin.GetType();
                    DarkLog.Debug("Error thrown in OnMessageReceived event for " + type.FullName + " (" + type.Assembly.FullName + "), Exception: " + e);
                }
            }
            message.handled = handledByAny;
        }
开发者ID:JoshBlake,项目名称:DarkMultiPlayer,代码行数:24,代码来源:DMPPluginHandler.cs

示例4: SendWarpMessage

 //Called from warpWorker
 public void SendWarpMessage(byte[] messageData)
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.WARP_CONTROL;
     newMessage.data = messageData;
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:8,代码来源:NetworkWorker.cs

示例5: SendVesselRemove

 //Called from vesselWorker
 public void SendVesselRemove(string vesselID, bool isDockingUpdate)
 {
     DarkLog.Debug("Removing " + vesselID + " from the server");
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.VESSEL_REMOVE;
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write<int>(TimeSyncer.fetch.currentSubspace);
         mw.Write<double>(Planetarium.GetUniversalTime());
         mw.Write<string>(vesselID);
         mw.Write<bool>(isDockingUpdate);
         if (isDockingUpdate)
         {
             mw.Write<string>(Settings.fetch.playerName);
         }
         newMessage.data = mw.GetMessageBytes();
     }
     QueueOutgoingMessage(newMessage, false);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:20,代码来源:NetworkWorker.cs

示例6: SendTimeSync

 //Called from timeSyncer
 public void SendTimeSync()
 {
     byte[] messageBytes;
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write<long>(DateTime.UtcNow.Ticks);
         messageBytes = mw.GetMessageBytes();
     }
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.SYNC_TIME_REQUEST;
     newMessage.data = messageBytes;
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:14,代码来源:NetworkWorker.cs

示例7: SendScenarioModuleData

 //Called from vesselWorker
 public void SendScenarioModuleData(string[] scenarioNames, byte[][] scenarioData)
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.SCENARIO_DATA;
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write<string[]>(scenarioNames);
         foreach (byte[] scenarioBytes in scenarioData)
         {
             mw.Write<byte[]>(scenarioBytes);
         }
         newMessage.data = mw.GetMessageBytes();
     }
     DarkLog.Debug("Sending " + scenarioNames.Length + " scenario modules");
     QueueOutgoingMessage(newMessage, false);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:17,代码来源:NetworkWorker.cs

示例8: SendPlayerColorMessage

 //Called from PlayerColorWorker
 public void SendPlayerColorMessage(byte[] messageData)
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.PLAYER_COLOR;
     newMessage.data = messageData;
     QueueOutgoingMessage(newMessage, false);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:8,代码来源:NetworkWorker.cs

示例9: SendMotdRequest

 //Called from networkWorker
 public void SendMotdRequest()
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.MOTD_REQUEST;
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:7,代码来源:NetworkWorker.cs

示例10: SendKerbalsRequest

 private void SendKerbalsRequest()
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.KERBALS_REQUEST;
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:6,代码来源:NetworkWorker.cs

示例11: SendHeartBeat

 private void SendHeartBeat()
 {
     if (state >= ClientState.CONNECTED && sendMessageQueueHigh.Count == 0)
     {
         if ((UnityEngine.Time.realtimeSinceStartup - lastSendTime) > (Common.HEART_BEAT_INTERVAL / 1000))
         {
             lastSendTime = UnityEngine.Time.realtimeSinceStartup;
             ClientMessage newMessage = new ClientMessage();
             newMessage.type = ClientMessageType.HEARTBEAT;
             QueueOutgoingMessage(newMessage, true);
         }
     }
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:13,代码来源:NetworkWorker.cs

示例12: SendHandshakeRequest

 private void SendHandshakeRequest()
 {
     byte[] messageBytes;
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write<int>(Common.PROTOCOL_VERSION);
         mw.Write<string>(Settings.fetch.playerName);
         mw.Write<string>(Settings.fetch.playerGuid.ToString());
         mw.Write<string>(Common.PROGRAM_VERSION);
         messageBytes = mw.GetMessageBytes();
     }
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.HANDSHAKE_REQUEST;
     newMessage.data = messageBytes;
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:16,代码来源:NetworkWorker.cs

示例13: QueueOutgoingMessage

 private void QueueOutgoingMessage(ClientMessage message, bool highPriority)
 {
     lock (messageQueueLock)
     {
         if (highPriority)
         {
             sendMessageQueueHigh.Enqueue(message);
         }
         else
         {
             sendMessageQueueLow.Enqueue(message);
         }
     }
     SendOutgoingMessages();
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:15,代码来源:NetworkWorker.cs

示例14: SendVesselProtoMessage

 //Called from vesselWorker
 public void SendVesselProtoMessage(ProtoVessel vessel, bool isDockingUpdate, bool isFlyingUpdate)
 {
     //Defend against NaN orbits
     if (VesselHasNaNPosition(vessel))
     {
         DarkLog.Debug("Vessel " + vessel.vesselID + " has NaN position");
         return;
     }
     foreach (ProtoPartSnapshot pps in vessel.protoPartSnapshots)
     {
         foreach (ProtoCrewMember pcm in pps.protoModuleCrew.ToArray())
         {
             if (pcm.type == ProtoCrewMember.KerbalType.Tourist)
             {
                 pps.protoModuleCrew.Remove(pcm);
             }
         }
     }
     ConfigNode vesselNode = new ConfigNode();
     vessel.Save(vesselNode);
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.VESSEL_PROTO;
     byte[] vesselBytes = ConfigNodeSerializer.fetch.Serialize(vesselNode);
     File.WriteAllBytes(Path.Combine(KSPUtil.ApplicationRootPath, "lastVessel.txt"), vesselBytes);
     if (vesselBytes != null && vesselBytes.Length > 0)
     {
         UniverseSyncCache.fetch.QueueToCache(vesselBytes);
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<string>(vessel.vesselID.ToString());
             mw.Write<bool>(isDockingUpdate);
             mw.Write<bool>(isFlyingUpdate);
             mw.Write<byte[]>(Compression.CompressIfNeeded(vesselBytes));
             newMessage.data = mw.GetMessageBytes();
         }
         DarkLog.Debug("Sending vessel " + vessel.vesselID + ", name " + vessel.vesselName + ", type: " + vessel.vesselType + ", size: " + newMessage.data.Length);
         QueueOutgoingMessage(newMessage, false);
     }
     else
     {
         DarkLog.Debug("Failed to create byte[] data for " + vessel.vesselID);
     }
 }
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:45,代码来源:NetworkWorker.cs

示例15: SendScenarioModuleDataHighPriority

 // Same method as above, only that in this, the message is queued as high priority
 public void SendScenarioModuleDataHighPriority(string[] scenarioNames, byte[][] scenarioData)
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.SCENARIO_DATA;
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write<string[]>(scenarioNames);
         foreach (byte[] scenarioBytes in scenarioData)
         {
             mw.Write<byte[]>(Compression.CompressIfNeeded(scenarioBytes));
         }
         newMessage.data = mw.GetMessageBytes();
     }
     DarkLog.Debug("Sending " + scenarioNames.Length + " scenario modules (high priority)");
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:17,代码来源:NetworkWorker.cs


注:本文中的DarkMultiPlayerCommon.ClientMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。