疑问,有空可以测试一下。

这两个脚本都没有继承自monobehaviour是不是只需要写好后,不需要给物体上挂就可以运行发送数据了。

1, HoloToolkit 远程实时传输视频

2,传数据和架构的建立。

a,导入holotoolkit后,界面自动会多一个 HoloToolkit按钮。

运行服务器时holotoolkit----> sharing service -----> launch sharing service,这样服务器会运行起来。

如果运行时出现下面的错误

则需要把对应的资源包里面的External文件夹copy到本工程的Assets平级文件夹即可。

b,  每个客户端的建立只需要拖预制体:HoloToolkit/Sharing/Perfabs/Sharing就好了。

需要修改IP地址,或写为localhost.

c,数据传输和1完全一样。修改这两个脚本。

d Loacl client, 这两个脚本都需要。

step1, RemoteHeadManager.cs

    private void Update(){// Grab the current head transform and broadcast it to all the other users in the sessionTransform headTransform = Camera.main.transform;// Transform the head position and rotation from world space into local spaceVector3 headPosition = transform.InverseTransformPoint(headTransform.position);Quaternion headRotation = Quaternion.Inverse(transform.rotation) * headTransform.rotation;// CustomMessages.Instance.SendHeadTransform(headPosition, headRotation);// CustomMessages.Instance.SendHeadTransform();CustomMessages.Instance.Send_Messages();}CustomMessages.Instance.Send_Messages();}

step2, CustomMessages.cs

 
//发送数据的函数 public void Send_Messages() { // If we are connected to a session, broadcast our info if (serverConnection != null && serverConnection.IsConnected()) { // Create an outgoing network message to contain all the info we want to sendNetworkOutMessage msg = CreateMessage((byte)TestMessageID.HeadTransform); //把要发送的数据写这儿或在这儿从其他地方来调用,然后发送到服务器 //1,把要发送的数据先转换为
byte[] byteArray = ..... int inTest = 10; msg.Write(inTest); string str = "Hello Poem and poet!"; msg.Write(str);
//基础数据类型都可以通过这样的方式传送 double doubleTest = 3.14159; byte[] inTestArray = BitConverter.GetBytes(doubleTest); //byte[] data = inTestArray;2 把转换后byte[]数组的长度写入 msg.Write(Length); msg.Write(inTestArray.Length); //uint len = (uint)inTestArray.Length; 3, 把数据转化为要求发送的格式 msg.WriteArray(byteArray,(uint)Length); msg.WriteArray(inTestArray, (uint)inTestArray.Length); // Send the message as a broadcast, which will cause the server to forward it to all other users in the session. serverConnection.Broadcast( msg, MessagePriority.Immediate, MessageReliability.UnreliableSequenced, MessageChannel.Avatar); } }

e, Remote Client。如果只负责接受数据则只需要RemoteHeadManager个脚本,如果要发送数据则两个都需要。

step1, RemoteHeadManager

      private void Start(){//CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.HeadTransform] = UpdateHeadTransform;CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.HeadTransform] = Recv_OtherClientMesssages;// SharingStage should be valid at this point, but we may not be connected.if (SharingStage.Instance.IsConnected){Connected();}else{SharingStage.Instance.SharingManagerConnected += Connected;}}Recv_OtherClientMesssages;// SharingStage should be valid at this point, but we may not be connected.if (SharingStage.Instance.IsConnected){Connected();}else{SharingStage.Instance.SharingManagerConnected += Connected;}}

..........................

        //接受来自其他客户端的信息private void Recv_OtherClientMesssages(NetworkInMessage msg){// Parse the messagelong userID = msg.ReadInt64();int rec = msg.ReadInt32();Debug.Log("rec is " + rec);string str = msg.ReadString();Debug.Log("str" + str);int len = msg.ReadInt32();byte[] data = new byte[sizeof(double)];msg.ReadArray(data, (uint)len);double pi = BitConverter.ToDouble(data, 0);Debug.Log("pi" + pi);}Recv_OtherClientMesssages(NetworkInMessage msg){// Parse the messagelong userID = msg.ReadInt64();int rec = msg.ReadInt32();Debug.Log("rec is " + rec);string str = msg.ReadString();Debug.Log("str" + str);int len = msg.ReadInt32();byte[] data = new byte[sizeof(double)];msg.ReadArray(data, (uint)len);double pi = BitConverter.ToDouble(data, 0);Debug.Log("pi" + pi);}

step2, 如果要发数据写法和Local client的写法一样。

f, 如果unity5.6.3的程序运行没问题,在2017.3.1f的程序上直接打开时,选择我备份了的按钮,还有错误:

双击打开有错误的地方,只需要把VR修改为XR即可

holotoolkit 客户端与服务器架构的建立相关推荐

  1. MySQL的客户端/服务器架构

    以我们平时使用的微信为例,它其实是由两部分组成的,一部分是客户端程序,一部分是服务器程序.客户端可能有很多种形式,比如手机APP,电脑软件或者是网页版微信,每个客户端都有一个唯一的用户名,就是你的微信 ...

  2. 客户端跟服务器通讯如何选择协议,客户端怎么和服务器通信协议

    客户端怎么和服务器通信协议 内容精选 换一换 TCP :传输控制协议(TCP),是互联网协议组的主要协议之一.它起源于最初的网络实施,在网络实施中,它补充了互联网协议.UDP: 用户数据报协议(Use ...

  3. GBASE 8s客户端与服务器的通信

    GBase客户端与服务器的通信支持多种不同的方式:共享内存 Shared memory.Stream pipe. TCP/IP(Sockets.TLI).IPX/SPX.DRDA.我们通常选择TCP/ ...

  4. bs客户端跨服务器管理文件,bs架构客户端和服务器

    bs架构客户端和服务器 内容精选 换一换 SSL(安全套接层,Secure Sockets Layer)是一种安全协议,目的是为互联网通信,提供安全及数据完整性保障.云容器实例支持上传SSL证书,在使 ...

  5. 基石为勤能补拙的迷宫之旅——客户端/服务器架构,OSI模型

    一.客户端/服务器架构     服务器就是一系列硬件或软件,为一个或多个客户端(服务的用户)提供所需的"服务".它存在唯一目的就是等待客户端的请求,并响应它们(提供服务),然后等待 ...

  6. bs架构的系统需要服务器吗,bs架构客户端和服务器

    bs架构客户端和服务器 内容精选 换一换 该操作指导安装工程师安装MRS集群所有服务(不包含Flume)的客户端.MRS针对不同服务提供了Shell脚本,供开发维护人员在不同场景下登录其对应的服务维护 ...

  7. 客户端与服务器(C/S架构与B/S架构)、AJax学习

    文章目录 HTTP请求与服务器 客户端与服务器 1.C/S架构与B/S架构 2.web资源介绍 3.资源访问流程 HTTP协议 1.什么是协议? 2.什么是HTTP协议 3.HTTP组成部分 4.请求 ...

  8. 客户端C和服务器S之间建立一个TCP连接,该连接总是以1KB的最大段长发送TCP段,客户端C有足够的数据要发送。当拥塞窗口为16KB的时候发生超时,如果接下来的4个RTT往返时间内的TCP段的传输是成

    客户端C和服务器S之间建立一个TCP连接,该连接总是以1KB的最大段长发送TCP段,客户端C有足够的数据要发送.当拥塞窗口为16KB的时候发生超时,如果接下来的4个RTT往返时间内的TCP段的传输是成 ...

  9. [ActionScript 3.0] NetConnection建立客户端与服务器的双向连接

    一个客户端与服务器之间的接口测试的工具 <?xml version="1.0" encoding="utf-8"?> <!--- - - - ...

  10. Android 架构之路 (1)-- Android 客户端与服务器的数据交互总结

    前言: 本文总结了 Android 客户端与服务器进行交互时,采用RESTful API +Json的交互方式,针对不同的数据形式以及不同的解析方法,如有不足之处,欢迎指正. 文章目录 1. Andr ...

最新文章

  1. edgesForExtendedLayout、automaticallyAdjustsScrollV
  2. JavaScript类型判断
  3. DASH直播平台的搭建
  4. python基础list_Python基础4(list:列表)
  5. Provided path doesn't exist. pylama Please fix pylama path or install latest version(UBuntu版本下的情况)
  6. 求n的阶乘的算法框图_单片机常用的14个C语言算法
  7. python作业:高级FTP程序
  8. 思考:那么些大学生仅凭个人好恶来判断,缺乏是非观
  9. 谁再问你“天天爬那些数据有什么用”,就把这5本书扔给他!
  10. asp.net 性能优化细节
  11. rstudio server docker 部署_Docker环境运行Spring Cloud项目
  12. doc转换html软件,Doc文件格式转换工具(CoolUtils Total Doc Converter)
  13. STM32 vcap引脚
  14. 关于Generator expression must be parenthesized  out报错或者Error creating Django application: Error on pyt
  15. 如何让自己时刻冷静的方法_如何做到时刻保持冷静
  16. 优雅使用Jsdelivr/CDN加速博客访问速度
  17. 综合日语第一册第六课
  18. 发送候选文字到光标所在位置
  19. os.path.dirname用法
  20. mac电脑抹掉数据要多久_Mac电脑如何恢复出厂设置?

热门文章

  1. python中pickle模块无法导入_python pickle模块
  2. y电容如何选型_到底什么是安规电容?有什么作用?一文彻底请明白
  3. docker swarm英文文档学习-11-上锁你的集群来保护你的加密密钥
  4. 谁先看到苏神咬人? 世界杯直播背后的云
  5. Tapestry 教程(四)探索项目结构
  6. Oracle 安装报错 [INS-06101] IP address of localhost...
  7. win7和xp,哪个才是你的选择?
  8. Jquery.EasyUI datebox控件
  9. 《Elementary Methods in Number Theory》勘误
  10. 在CentOS6.0 上安装LAMP