public void Pack()
        {
            byte[] buffer = new byte[8];
            BitConverter.GetBytes(ip).CopyTo(buffer, 0);
            BitConverter.GetBytes(port).CopyTo(buffer, 4);

            data = new QsPackageData(buffer);
            header = new QsPackageHeader((int)QsFarmer.QsITaskFactory.QsTaskType.QsETaskFarmerRegister, data);
        }
Пример #2
0
 public void ReceiveHeaderCallback(IAsyncResult ar)
 {
     QsNetIOStateObject headerState = (QsNetIOStateObject)ar.AsyncState;
     int bytesRead = receiveSocket.EndReceive(ar);
     if (bytesRead > 0)
     {
         headerState.count += bytesRead;
         if (headerState.count < QsPackageHeader.headerBufferSize)
             receiveSocket.BeginReceive(header.headerBuffer, headerState.count, QsPackageHeader.headerBufferSize - headerState.count, 0, new AsyncCallback(ReceiveHeaderCallback), headerState);
         else
         {
             QsNetIOStateObject dataState = new QsNetIOStateObject();
             data = new QsPackageData(header.GetDataLength());
             receiveSocket.BeginReceive(data.dataBuffer, dataState.count, data.dataLength - dataState.count, 0, new AsyncCallback(ReceiveDataCallback), dataState);
         }
     }
 }
Пример #3
0
 public QsPackageHeader(int cmdType, QsPackageData data)
 {
     headerBuffer[0] = (byte)cmdType;
     BitConverter.GetBytes(data.dataLength).CopyTo(headerBuffer, 1);
 }
Пример #4
0
 public void SetPackageData(QsPackageData d)
 {
     data = d;
 }
Пример #5
0
 public QsNetIOSender(Socket s, QsPackageHeader h, QsPackageData d)
 {
     sendSocket = s;
     header = h;
     data = d;
 }
Пример #6
0
 public QsNetIOSender(string ip, int port, QsPackageHeader h, QsPackageData d)
 {
     Connect(ip, port);
     header = h;
     data = d;
 }
 public int UnPack(QsPackageHeader header, QsPackageData data)
 {
     return 0;
 }