Merge branch 'master' of http://172.16.1.12/yulong/NewN_UAVPlane
This commit is contained in:
commit
4e927017dc
|
@ -11,10 +11,6 @@ using Newtonsoft.Json.Linq;
|
|||
public class LoadManage : MonoBehaviour
|
||||
{
|
||||
public static LoadManage Instance;
|
||||
|
||||
/// <summary>
|
||||
/// 房间域 "Room"
|
||||
/// </summary>
|
||||
[DisplayOnly]
|
||||
public string currentRoomArea;
|
||||
[DisplayOnly]
|
||||
|
@ -52,9 +48,6 @@ public class LoadManage : MonoBehaviour
|
|||
SceneManager.LoadScene("SampleScene");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建与roomServer通信的客户端
|
||||
/// </summary>
|
||||
public void CreateRoomServerClient(string roomServerSubIP, string roomServerPubIP)
|
||||
{
|
||||
if (RSclient == null)
|
||||
|
@ -78,10 +71,6 @@ public class LoadManage : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RoomServer,mono
|
||||
/// </summary>
|
||||
/// <param name="stS"></param>
|
||||
private void ReciveFromRoomServerInThread(st_Motions stS)
|
||||
{
|
||||
RSclient._netMqListener.AddToMono(stS);
|
||||
|
|
|
@ -38,10 +38,6 @@ public class MyNetMQClient : MonoBehaviour
|
|||
instance = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化Netmq
|
||||
/// </summary>
|
||||
/// <param name="reciveInMono">接收函数</param>
|
||||
public void Init(string ServerSubIP,string ServerPubIP, NetMqListener.ReciveMessageInThread reciveInthread, NetMqListener.ReceiceMessageInMono reciveInMono,string typename)
|
||||
{
|
||||
SubIP = ServerSubIP;
|
||||
|
@ -104,15 +100,6 @@ public class st_Motions
|
|||
public byte[] m_sOperaData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 演习状态
|
||||
/// </summary>
|
||||
public enum ProgramState
|
||||
{
|
||||
结束,
|
||||
进行中
|
||||
}
|
||||
|
||||
public class DisplayOnly : PropertyAttribute
|
||||
{
|
||||
|
||||
|
|
|
@ -8,40 +8,18 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订阅模块
|
||||
/// </summary>
|
||||
public class NetMqListener
|
||||
{
|
||||
private string serverSubIP;
|
||||
|
||||
private Thread _listenerWorker;
|
||||
public bool _listenerCancelled;
|
||||
/// <summary>
|
||||
/// 自定义名称
|
||||
/// </summary>
|
||||
public string typeName;
|
||||
/// <summary>
|
||||
/// 处理函数委托
|
||||
/// </summary>
|
||||
/// <param name="st"></param>
|
||||
public delegate void ReceiceMessageInMono(st_Motions st);
|
||||
public delegate void ReciveMessageInThread(st_Motions st);
|
||||
/// <summary>
|
||||
/// mono里处理消息
|
||||
/// </summary>
|
||||
private readonly ReceiceMessageInMono _reciveMessageInMono;
|
||||
/// <summary>
|
||||
/// 线程里处理模型
|
||||
/// </summary>
|
||||
private readonly ReciveMessageInThread _reciveMessageInThread;
|
||||
|
||||
private readonly List<st_Motions> _messageReciveStmotion = new List<st_Motions>();
|
||||
|
||||
/// <summary>
|
||||
/// 注册委托函数
|
||||
/// </summary>
|
||||
public NetMqListener(string subIP , ReciveMessageInThread _reciveInThread, ReceiceMessageInMono reciveInMono)
|
||||
{
|
||||
serverSubIP = subIP;
|
||||
|
@ -49,9 +27,7 @@ public class NetMqListener
|
|||
_reciveMessageInMono += reciveInMono;
|
||||
StartListen();
|
||||
}
|
||||
/// <summary>
|
||||
/// 开始监听
|
||||
/// </summary>
|
||||
|
||||
public void StartListen()
|
||||
{
|
||||
_listenerCancelled = false;
|
||||
|
@ -59,9 +35,7 @@ public class NetMqListener
|
|||
_listenerWorker.IsBackground = true;
|
||||
_listenerWorker.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// 停止监听
|
||||
/// </summary>
|
||||
|
||||
public void StopListen()
|
||||
{
|
||||
_listenerCancelled = true;
|
||||
|
@ -69,9 +43,6 @@ public class NetMqListener
|
|||
}
|
||||
|
||||
public SubscriberSocket subSocket;
|
||||
/// <summary>
|
||||
/// 接收线程
|
||||
/// </summary>
|
||||
private void ByteListenerWork()
|
||||
{
|
||||
AsyncIO.ForceDotNet.Force();
|
||||
|
@ -87,7 +58,6 @@ public class NetMqListener
|
|||
//{
|
||||
List<byte[]> frameByte = new List<byte[]>();
|
||||
if (!subSocket.TryReceiveMultipartBytes(ref frameByte)) continue;
|
||||
//UnityEngine.Debug.Log("线程收到一条");
|
||||
st_Motions stS = new st_Motions();
|
||||
string tmp = Encoding.UTF8.GetString(frameByte[0]);
|
||||
stS.m_iOperaType = BitConverter.ToInt32(frameByte[1], 0);
|
||||
|
|
|
@ -16,15 +16,9 @@ public class NetMqPublisher
|
|||
|
||||
private Thread _listenerWorker;
|
||||
public bool _listenerCancelled;
|
||||
/// <summary>
|
||||
/// 自定义名称
|
||||
/// </summary>
|
||||
public string typeName;
|
||||
public delegate void MessageDelegateByte(st_Motions st);
|
||||
private readonly MessageDelegateByte _messageDelegateByte;
|
||||
/// <summary>
|
||||
/// 发送队列
|
||||
/// </summary>
|
||||
private readonly ConcurrentQueue<st_Motions> _messageQueueData = new ConcurrentQueue<st_Motions>();
|
||||
|
||||
|
||||
|
@ -33,10 +27,6 @@ public class NetMqPublisher
|
|||
serverPubIP = pubIP;
|
||||
StartListen();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始监听
|
||||
/// </summary>
|
||||
public void StartListen()
|
||||
{
|
||||
_listenerCancelled = false;
|
||||
|
@ -44,17 +34,12 @@ public class NetMqPublisher
|
|||
_listenerWorker.IsBackground = true;
|
||||
_listenerWorker.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// 停止监听
|
||||
/// </summary>
|
||||
public void StopListen()
|
||||
{
|
||||
_listenerCancelled = true;
|
||||
//_listenerWorker.Join();
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送线程
|
||||
/// </summary>
|
||||
|
||||
private void ByteListenerWork()
|
||||
{
|
||||
AsyncIO.ForceDotNet.Force();
|
||||
|
@ -78,7 +63,6 @@ public class NetMqPublisher
|
|||
Array.Copy(BitConverter.GetBytes(sendData.m_iOperaType), 0, tmpbytes, 0, 4);
|
||||
Array.Copy(sendData.m_sOperaData, 0, tmpbytes, 4, sendData.m_sOperaData.Length);
|
||||
if (!_listenerCancelled && !publishSocket.SendMoreFrame(sendData.area).TrySendFrame(tmpbytes)) continue;
|
||||
UnityEngine.Debug.Log("发送一个消息:" + sendData.area + "," + sendData.m_iOperaType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue