/// <summary> /// 生成重复连接错误的报文字节码 /// </summary> /// <returns>Byte[] struct UVA_RESPONSE转换出的字节码</returns> public static Byte[] Error(char errorType) { UVA_RESPONSE repMsg = new UVA_RESPONSE(); //'\u0003':error //'\u0001':DuplicateConnection //更多错误消息的定义,请查看通信协议 repMsg.sendType = Global.cmdTypeERROR; repMsg.errorType = errorType; return(StructToBytes(repMsg)); }
/// <summary> /// 生成close命令 /// </summary> /// <returns></returns> public static byte[] Close() { //throw new NotImplementedException(); UVA_RESPONSE repMsg = new UVA_RESPONSE(); //'\u0003':error //'\u0001':DuplicateConnection //更多错误消息的定义,请查看通信协议 repMsg.sendType = Global.cmdTypeCLOSE; //repMsg.errorType = errorType; return(StructToBytes(repMsg)); }
/// <summary> /// 生成ready的信息 /// </summary> public static Byte[] Ready(string ip, int port) { string[] ips = ip.Split('.'); int ipFirst = Convert.ToInt32(ips[0]); int ipSecond = Convert.ToInt32(ips[1]); int ipThird = Convert.ToInt32(ips[2]); int ipFourth = Convert.ToInt32(ips[3]); UVA_RESPONSE repMsg = new UVA_RESPONSE(); repMsg.sendType = Global.cmdTypeREADY; repMsg.IPFirst = ipFirst; repMsg.IPSecond = ipSecond; repMsg.IPThird = ipThird; repMsg.IPFourth = ipFourth; repMsg.Port = port; return(StructToBytes(repMsg)); }
/// <summary> /// 生成心跳响应的信息 /// </summary> public static Byte[] HeratResponse(UvaEntity uvaT) { UVA_RESPONSE repMsg = new UVA_RESPONSE(); string ip = Global.cpeIP; string[] ips = ip.Split('.'); int ipFirst = Convert.ToInt32(ips[0]); int ipSecond = Convert.ToInt32(ips[1]); int ipThird = Convert.ToInt32(ips[2]); int ipFourth = Convert.ToInt32(ips[3]); repMsg.IPFirst = ipFirst; repMsg.IPSecond = ipSecond; repMsg.IPThird = ipThird; repMsg.IPFourth = ipFourth; //repMsg.Port = uvaT.videoPort; repMsg.Port = Global.cpePort; repMsg.sendType = '\u0002'; repMsg.bandWidth = uvaT.bandWidth; //把ip和端口补充上 /*string[] ips = uvaT.videoIp.Split('.'); * int ipFirst = Convert.ToInt32(ips[0]); * int ipSecond = Convert.ToInt32(ips[1]); * int ipThird = Convert.ToInt32(ips[2]); * int ipFourth = Convert.ToInt32(ips[3]); * * repMsg.sendType = Global.cmdTypeREADY; * repMsg.IPFirst = ipFirst; * repMsg.IPSecond = ipSecond; * repMsg.IPThird = ipThird; * repMsg.IPFourth = ipFourth; * repMsg.Port = uvaT.videoPort;*/ return(StructToBytes(repMsg)); }
/// <summary> /// 生成重复连接错误的报文字节码 /// </summary> /// <returns>Byte[] struct UVA_RESPONSE转换出的字节码</returns> public static Byte [] DuplicateConnection(string ip, int port) { UVA_RESPONSE repMsg = new UVA_RESPONSE(); //'\u0003':error //'\u0001':DuplicateConnection //更多错误消息的定义,请查看通信协议 repMsg.sendType = Global.cmdTypeERROR; repMsg.errorType = '\u0001'; string[] ips = ip.Split('.'); int ipFirst = Convert.ToInt32(ips[0]); int ipSecond = Convert.ToInt32(ips[1]); int ipThird = Convert.ToInt32(ips[2]); int ipFourth = Convert.ToInt32(ips[3]); // UVA_RESPONSE repMsg = new UVA_RESPONSE(); // repMsg.sendType = '\u0001'; repMsg.IPFirst = ipFirst; repMsg.IPSecond = ipSecond; repMsg.IPThird = ipThird; repMsg.IPFourth = ipFourth; repMsg.Port = port; return(StructToBytes(repMsg)); }