zoukankan      html  css  js  c++  java
  • UE4 nDisplay外部应用发送ClusterEvent

    private int SendClusterCommand(string nodeAddress, int port, string cmd, bool bQuiet = false)
            {
                int ResponseCode = 1;
                TcpClient nodeClient = new TcpClient();
    
                if (!bQuiet)
                {
                    AppLogger.Log(string.Format("Sending command {0} to {1}...", cmd, nodeAddress));
                }
    
                try
                {
                    // Connect to the listener
                    nodeClient.Connect(nodeAddress, port);
                    NetworkStream networkStream = nodeClient.GetStream();
    
                    byte[] OutData = ASCIIEncoding.ASCII.GetBytes(cmd);
                    byte[] OutSize = BitConverter.GetBytes((short)OutData.Length);
    
                    networkStream.Write(OutSize, 0, OutSize.Length);
                    networkStream.Write(OutData, 0, OutData.Length);
                    AppLogger.Log("Event sent");
    
                    byte[] InLength = new byte[2];
                    int InBytesCount = networkStream.Read(InLength, 0, 2);
                    AppLogger.Log("Received " + InBytesCount + " bytes");
    
                    int MessageSize = InLength[0] + ((UInt16)InLength[1] << 8);
                    byte[] InData = new byte[MessageSize];
                    InBytesCount = networkStream.Read(InData, 0, MessageSize);
                    AppLogger.Log("Received " + InBytesCount + " bytes");
    
                    string Response = ASCIIEncoding.ASCII.GetString(InData, 0, InBytesCount);
                    AppLogger.Log("Response " + Response);
                }
                catch (Exception ex)
                {
                    if (!bQuiet)
                    {
                        AppLogger.Log("An error occurred while sending a command to " + nodeAddress + ". EXCEPTION: " + ex.Message);
                    }
                }
                finally
                {
                    nodeClient.Close();
                }
    
                return ResponseCode;
            }

    出自UE4源码。

    cmd参数的构造:

    {

      "Category" : "",

      "Type" : "",

      "Name" : "",

      "Parameters":{},

    }

    名称(Name)类型(Type) 和 类别(Category) 字段为必填字段,但可以忽略参数(Parameters)字段。

    具体写法可以使用nDisplayLauncher发送一个Cluster Event然后看日志:

     

  • 相关阅读:
    sed命令
    awk命令
    let命令
    首先看一下友晶DE-SOC开发板的user manual
    嵌入式FIFO核的调用
    嵌入式ROM核的调用
    用嵌入式块RAM IP核配置一个双口RAM
    如何利用Visio设计一个系统的结构图
    uart通讯协议
    按键消抖试验及一个数码管电子时钟的设计
  • 原文地址:https://www.cnblogs.com/CodeSnippet/p/11375804.html
Copyright © 2011-2022 走看看