// 送信データ作成 public static void Send(HvNetworkIO net, ServerCommand command, float data) { net.Writer.Begin(HvNetworkIO.Command.ServerCommand, (BinaryWriter writer) => { writer.Write((int)command); writer.Write(data); }); net.Log($"send : server command[{command.ToString()}] value[{data}]"); }
// 送信データ作成 public static void Send(HvNetworkIO net, IntPtr buffer, int size) { try { net.Writer.Begin(HvNetworkIO.Command.Decode, buffer, size); } catch { } }
// 送信データ作成 public static void Send(HvNetworkIO net, int width, int height) { net.Writer.Begin(HvNetworkIO.Command.ClientSetting, (BinaryWriter writer) => { writer.Write(width); writer.Write(height); }); net.Log($"send : [{width},{height}]"); }
// 送信データ作成 public static void Send(HvNetworkIO net, int width, int height, int bufferSize) { net.Writer.Begin(HvNetworkIO.Command.StartInfo, (BinaryWriter writer) => { writer.Write(width); writer.Write(height); writer.Write(bufferSize); }); net.Log($"send : size[{width},{height}] bufferSize[{bufferSize}]"); }
// クライアント接続テスト public async Task TestClient(IPAddress ipaddr, int port) { await Task.Delay(1000); var netIO = new HvNetworkIO(); try { Debug.Log("TestClient : -Start TestClient"); _decoder = netIO.GetResever <HvNetDecoder>(); netIO.Prefix = "client"; var client = new TcpClient(ipaddr.ToString(), port); netIO.Begin(client); // 接続開始 // Test送信 HvNetIOTest.Send(netIO); // クライアント情報送信 HvNetIOClientInfo.Send(netIO, Quaternion.identity, -1); try { do { Thread.Sleep(500); } while (netIO.IsConnected && _playClient); } catch (Exception e) { Debug.Log($"client error : {e.Message}"); } Debug.Log("TestClient : out loop"); } catch (Exception e) { Debug.Log(e.Message); throw; } finally { netIO.CloseNetwork(); Thread.Sleep(50); netIO.Dispose(); Debug.Log("-End TestClient"); } }
// 送信データ作成 public static void Send(HvNetworkIO net, Quaternion cameraRot, int imageId) { net.Writer.Begin(HvNetworkIO.Command.ClientInfo, (BinaryWriter writer) => { // 傾き情報 writer.Write(cameraRot.x); writer.Write(cameraRot.y); writer.Write(cameraRot.z); writer.Write(cameraRot.w); writer.Write(imageId); // クライアントが最後に処理したフレーム }); net.Log($"send : [{cameraRot}]"); }
// 送信データ作成 public static bool Send(HvNetworkIO net, IntPtr buffer, int size) { return(net.Writer.Begin(HvNetworkIO.Command.OggDecode, buffer, size)); }
// 終了コマンド作成 public static void SendEndCommand(HvNetworkIO net) { net.Writer.Begin(HvNetworkIO.Command.End, IntPtr.Zero, 0); }
// セットアップ public void Setup(HvNetworkIO owner) { Owner = owner; this.Setup(); }