private void PostData(DataChunk c) { NetIncomingMessage msg = new NetIncomingMessage(NetIncomingMessageType.Data); msg.LengthBits = c.BitLength; msg.LengthBytes = (int)Math.Ceiling((double)c.BitLength / 8); msg.Data = c.Data; JNet.GetClient().InjectDataMessage(msg); }
private void StartClient() { JNet.StartClient(); JNet.GetClient().UponConnect = () => { Debug.Log($"Client connected."); }; JNet.GetClient().UponDisconnect = (reason) => { Debug.Log($"Client disconnected. ({reason})"); }; JNet.GetClient().UponCustomData = (id, msg) => { switch (id) { case CustomMsg.PROJECTILE_SPAWN: Projectile.ProcessMessage(msg); break; case CustomMsg.AUTO_DESTROY_SPAWN: AutoDestroy.ProcessMessage(msg); break; default: Debug.LogError($"Unhandled custom data id: {id}"); break; } }; if (record) { StartRecording(); } if (JNet.IsServer) { JNet.ConnectClientToHost(null); } else { JNet.ConnectClientToRemote("127.0.0.1", 7777); } }