public byte[] PlayVideo(byte [] beforeVideo, ref bool newFlag) { Array.Clear(buffVideo, 0, buffVideo.Length); int byteBuff = socket.Receive(buffVideo); VideoData video = Coder.DecodeVideo(byteBuff, buffVideo, beforeVideo); newFlag = video.NewFlag; return(video.Data); }
public string Login(string ip, int port) { string strResult = string.Empty; if (!NetHelper.Connect(socket, ip, port)) { strResult = "连接失败"; } else { byte[] buff; Coder.EncodeLogin1(out buff); socket.Send(buff); byte[] buffReceive = new byte[BUFFER_SIZE]; int byteBuff = socket.Receive(buffReceive); NormalDataStruct dataInfo = Coder.DecodeData(buffReceive); Login1Struct loginInfo = Coder.DecodeLogin1(dataInfo.Content); Coder.EncodeLogin2(out buff); socket.Send(buff); byteBuff = socket.Receive(buffReceive); dataInfo = Coder.DecodeData(buffReceive); enumRespResult loginResult = Coder.DecodeResult(dataInfo.Content); if (loginResult != enumRespResult.Success) { strResult = loginResult.ToString(); } else { Coder.EncodePlayVedio(out buff); socket.Send(buff); byteBuff = socket.Receive(buffReceive); dataInfo = Coder.DecodeData(buffReceive); enumRespResult playResult = Coder.DecodeResult(dataInfo.Content); if (playResult != enumRespResult.Success) { strResult = playResult.ToString(); } else { connectFlag = true; //byte[] buffVedio = new byte[] { }; //while (true) //{ // buffVedio = this.PlayVideo(buffVedio); //} } } //string strMsg = ConvertHelper.BytesToString(buff, System.Text.Encoding.UTF8); //Console.WriteLine(strMsg); } return(strResult); }
public string ConnectWifi() { string strResult = string.Empty; IPEndPoint targetPoint = new IPEndPoint(IPAddress.Broadcast, PORT_SEARCH); byte[] buff; Coder.EncodeWifiSearch(out buff); client.EnableBroadcast = true; client.Send(buff, 5, targetPoint); return(strResult); }
public void RespConnectWifi() { IPEndPoint serverPoint = new IPEndPoint(IPAddress.Any, 0); while (!connectFlag) { try { byte[] buff = client.Receive(ref serverPoint); WifiRespInfo info = Coder.DecodeWifiSearch(buff); Login(info.IP, info.Port); } catch { } } }
public void KeepAlive() { byte[] buff; Coder.EncodeKeepAlive(out buff); socket.Send(buff); }