示例#1
0
        void IPduReceivedHandler.HandlePdu(BindReceiverResponse pdu)
        {
            var task = _taskRegistry.Unregister(pdu.SequenceNumber);
            if (task == null)
                return;

            if (pdu.Status != SmppStatus.Ok)
            {
                var bindException = new Exception("The bind operation failed with error code: " + pdu.Status);
                task.SetException(bindException);
            }
            else
            {
                _state = SessionState.BoundReceiver;
                task.SetResult(new BindResult(pdu.SystemId));
            }
        }
        public void Serializes_Pdu()
        {
            var expectedResult = new byte[] {
                0x00, 0x00, 0x00, 0x17, // length
                0x80, 0x00, 0x00, 0x01, // command
                0x00, 0x00, 0x00, 0x00, // status
                0x00, 0x00, 0x00, 0x20, // sequence
                0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x00 // system ID
            };
            var pdu = new BindReceiverResponse(
                SmppStatus.Ok,
                32,
                "System");
            var serializer = new BindReceiverResponseSerializer();

            var result = serializer.Serialize(pdu);

            CollectionAssert.AreEqual(expectedResult, result);
        }