public CmdGetActivationCode(ClientManager mngr, SendMsg sendMsg) { this.mngr = mngr; string msg_content = System.Text.Encoding.ASCII.GetString(sendMsg.msg_content); string[] args = msg_content.Split(new char[] { ',' }); for (int i = 0; i < args.Length; i++) args[i] = args[i].Trim(); if (args.Length > 0) softwareName = args[0]; if (args.Length > 1) encodingStr = args[1]; }
public string GetActivationCode(string softwareName, string encodingStr) { SendMsg sendMsg = new SendMsg(MsgType.GetActivationCode, softwareName, encodingStr); Send(sendMsg); RetMsg retMsg = Receive(); string retVal = System.Text.Encoding.ASCII.GetString(retMsg.ret_content); if (retMsg.retCode == RetCode.Successful) return retVal; else throw new LicenseClientException(retVal); }
private int Send(SendMsg sendMsg) { int total_send = 0; byte[] typeBuffer = new byte[4]; typeBuffer = BitConverter.GetBytes((int)sendMsg.msgType); total_send += _clientSD.Send(typeBuffer, 0, 4, SocketFlags.None); byte[] contentLenBuffer = new byte[4]; contentLenBuffer = BitConverter.GetBytes(sendMsg.msg_content_len); total_send += _clientSD.Send(contentLenBuffer, 0, 4, SocketFlags.None); if (sendMsg.msg_content.Length != 0) total_send += _clientSD.Send(sendMsg.msg_content, 0, sendMsg.msg_content.Length, SocketFlags.None); return total_send; }
public LicenseCommand(IPAddress ip, int port, SendMsg sendMsg) { this.ip = ip; this.port = port; this.sendMsg = sendMsg; }