// ************* Private methods below *********************************** // private void SendHandshake() { // When first connected, buffer handshake data for send. DebugLog("Send Handshake"); TcpMessageBuilder.NewMessage(EDITOR_MESSAGE_HANDSHAKE, messageBuffer_) .Add(PLAYER_ID) .Add(PLAYER_PROTOCOL) .Write(writeBuffer_, copyBuffer_); TcpMessageBuilder.NewMessage(EDITOR_MESSAGE_CAMERAS, messageBuffer_) .Add((uint)0) .Write(writeBuffer_, copyBuffer_); }
private void SendBufferedEvents() { // Buffer device size info for send. if (deviceScreenSize_.screenWidth != 0 || deviceScreenSize_.screenHeight == 0) { DebugLog("Send device size"); TcpMessageBuilder.NewMessage(EDITOR_MESSAGE_DEVICE_SIZE, messageBuffer_) .Add(deviceScreenSize_.screenWidth) .Add(deviceScreenSize_.screenHeight) .Write(writeBuffer_, copyBuffer_); deviceScreenSize_.screenWidth = 0; deviceScreenSize_.screenHeight = 0; } // Buffer dvice orientation info for send. if (deviceOrientation_.deviceOrientation != (int)DeviceOrientation.Unknown) { DebugLog("SendDeviceOrientation"); TcpMessageBuilder.NewMessage(EDITOR_MESSAGE_DEVICE_ORIENTATION, messageBuffer_) .Add(deviceOrientation_.deviceOrientation) .Write(writeBuffer_, copyBuffer_); deviceOrientation_.deviceOrientation = (int)DeviceOrientation.Unknown; } // Buffer touch info for send. foreach (var touch in touches_) { DebugLog("SendTouchInput"); TcpMessageBuilder.NewMessage(EDITOR_MESSAGE_TOUCHES, messageBuffer_) .Add(touch.positionX) .Add(touch.positionY) .Add(touch.frameCount) .Add(touch.fingerId) .Add(touch.phase) .Add(touch.tapCount) .Write(writeBuffer_, copyBuffer_); } touches_.Clear(); // Send buffered data and clear the buffer. writeBuffer_.Position = 0; PartialCopyTo(writeBuffer_, tcp_.GetStream(), copyBuffer_, (int)writeBuffer_.Length); writeBuffer_.Position = 0; writeBuffer_.SetLength(0); }