• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DarkMultiPlayerCommon.ClientMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SendKerbalProtoMessage

 //Called from vesselWorker
 public void SendKerbalProtoMessage(ProtoCrewMember kerbal)
 {
     ConfigNode kerbalNode = new ConfigNode();
     kerbal.Save(kerbalNode);
     byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
     if (kerbalBytes != null && kerbalBytes.Length > 0)
     {
         ClientMessage newMessage = new ClientMessage();
         newMessage.type = ClientMessageType.KERBAL_PROTO;
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<string>(kerbal.name);
             mw.Write<byte[]>(kerbalBytes);
             newMessage.data = mw.GetMessageBytes();
         }
         DarkLog.Debug("Sending kerbal " + kerbal.name + ", size: " + newMessage.data.Length);
         QueueOutgoingMessage(newMessage, false);
     }
     else
     {
         DarkLog.Debug("Failed to create byte[] data for kerbal " + kerbal.name);
     }
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:25,代码来源:NetworkWorker.cs


示例17: SendLockSystemMessage

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


示例18: SendNetworkMessage

 private void SendNetworkMessage(ClientMessage message)
 {
     byte[] messageBytes;
     using (MessageWriter mw = new MessageWriter((int)message.type))
     {
         if (message.data != null)
         {
             mw.Write<byte[]>(message.data);
         }
         messageBytes = mw.GetMessageBytes();
     }
     //Disconnect after EndWrite completes
     if (message.type == ClientMessageType.CONNECTION_END)
     {
         using (MessageReader mr = new MessageReader(message.data, false))
         {
             terminateOnNextMessageSend = true;
             connectionEndReason = mr.Read<string>();
         }
     }
     isSendingMessage = true;
     lastSendTime = UnityEngine.Time.realtimeSinceStartup;
     try
     {
         clientConnection.GetStream().BeginWrite(messageBytes, 0, messageBytes.Length, new AsyncCallback(SendCallback), null);
     }
     catch (Exception e)
     {
         HandleDisconnectException(e);
     }
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:31,代码来源:NetworkWorker.cs


示例19: SendPingRequest

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


示例20: SendVesselsRequest

 private void SendVesselsRequest(string[] requestList)
 {
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.VESSELS_REQUEST;
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write<string[]>(requestList);
         newMessage.data = mw.GetMessageBytes();
     }
     QueueOutgoingMessage(newMessage, true);
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:11,代码来源:NetworkWorker.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DarkMultiPlayerCommon.ServerMessage类代码示例发布时间:2022-05-24
下一篇:
C# Dapper.DynamicParameters类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap