/// <summary> /// 不断的发送消息 /// </summary> private void SendMessage() { byte[] byteMessage; RandomPoints.GetRandomCarLocations oGetCarLocations = new GPSGatewaySimulator.RandomPoints.GetRandomCarLocations(); do { if (this._connnectionClosed == true) { byteMessage = CommnicationMessage.ObjectSerialize.SerializeObjectToBytes(new CommnicationMessage.GPSTrackingMessage(null, null, null, 0, 0, 0, DateTime.Now, true), CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat); this._socket.Send(byteMessage); break; } if (this._messageCollection == null) { this._messageCollection = oGetCarLocations.GetCarLocationsQueue(); this._messageCollection.TrimExcess(); } if (this._messageCollection.Count == 0) { this._messageCollection = null; continue; } byteMessage = CommnicationMessage.ObjectSerialize.SerializeObjectToBytes(this._messageCollection.Dequeue(), CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat); this._socket.Send(byteMessage); this._thread.Join(this._intervalue); }while (true); }
/// <summary> /// ���ϵķ�����Ϣ /// </summary> private void SendMessage() { byte[] byteMessage; RandomPoints.GetRandomCarLocations oGetCarLocations = new GPSGatewaySimulator.RandomPoints.GetRandomCarLocations(); do { if (this._connnectionClosed == true) { byteMessage = CommnicationMessage.ObjectSerialize.SerializeObjectToBytes(new CommnicationMessage.GPSTrackingMessage(null, null, null, 0, 0, 0, DateTime.Now, true), CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat); this._socket.Send(byteMessage); break; } if (this._messageCollection == null) { this._messageCollection = oGetCarLocations.GetCarLocationsQueue(); this._messageCollection.TrimExcess(); } if (this._messageCollection.Count == 0) { this._messageCollection = null; continue; } byteMessage = CommnicationMessage.ObjectSerialize.SerializeObjectToBytes(this._messageCollection.Dequeue(), CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat); this._socket.Send(byteMessage); this._thread.Join(this._intervalue); } while (true); }