private void sendCRPPacket(MySocket tcpSocket, int headType, CRPBody body) { byte[] bodyBytes = body.getBytes(); byte[] packet = new byte[CRPHead.length + bodyBytes.Length]; BytesUtil.Append(packet, CRPHead.getHeadBytes(headType)); BytesUtil.Append(packet, bodyBytes, CRPHead.length); tcpSocket.send(packet); }
public void sendVideoFrame(Bitmap frame) { ushort partOrder = 0; byte[] frameBytes = BytesUtil.bitmap2Bytes(frame); ushort partsNum = (ushort)(frameBytes.Length / UDPDATALENGTH + ((frameBytes.Length % UDPDATALENGTH == 0) ? 0 : 1)); List <byte[]> frameList = BytesUtil.divideBytes(frameBytes, UDPDATALENGTH); foreach (byte[] framePart in frameList) { var v = BytesUtil.catBytes(new VFHead(frameOrder, partsNum, partOrder++).getBytes(), framePart); udpSender.send(v, serverUDPPort); } frameOrder++; }
private void handleTCPData(byte[] data) { byte[] CRPData = BytesUtil.subBytes(data, CRPHead.LENGTH); byte[] head = BytesUtil.subBytes(data, 0, CRPHead.LENGTH); switch (checkDataType(head)) { case CRPHead.RESPONSE_LOGIN: handleLogin(CRPData); break; case CRPHead.FORWARD_MESSAGE: handleMessage(CRPData); break; case CRPHead.FORWARD_PICTURE: handlePicture(CRPData); break; case CRPHead.RESPONSE_VIDEO_START: handleVideoStart(CRPData); break; } }
private void handleMessage(byte[] data) { messageHandler.Invoke(BytesUtil.bytes2String(data)); }