Ejemplo n.º 1
0
        private void DealPersonalDeviceMessage(TopflytechCodec.Entities.Message message, Socket socket)
        {
            string strClientKey = socket.RemoteEndPoint.ToString();

            if (message is TopflytechCodec.Entities.SignInMessage)
            {
                SignInMessage signInMessage = (SignInMessage)message;
                ShowMsg("receive signIn Message imei :" + signInMessage.Imei + " serial no: " + signInMessage.SerialNo + " firmware :" + signInMessage.Firmware + " software: " + signInMessage.Software + "platform:" + signInMessage.Platform);
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = personalEncoder.getSignInMsgReply(signInMessage.Imei, true, signInMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = personalEncoder.getSignInMsgReply(signInMessage.Imei, true, signInMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.HeartbeatMessage)
            {
                HeartbeatMessage heartbeatMessage = (HeartbeatMessage)message;
                ShowMsg("receive heartbeat Message imei :" + heartbeatMessage.Imei + " serial no: " + heartbeatMessage.SerialNo);
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = personalEncoder.getHeartbeatMsgReply(heartbeatMessage.Imei, true, heartbeatMessage.SerialNo);
                //    dict[strClientKey].Send(reply);

                //}
                byte[] reply = personalEncoder.getHeartbeatMsgReply(heartbeatMessage.Imei, true, heartbeatMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.LocationInfoMessage)
            {
                LocationInfoMessage locationInfoMessage = (LocationInfoMessage)message;
                ShowMsg("receive location Info Message imei :" + locationInfoMessage.Imei + " serial no: " + locationInfoMessage.SerialNo);
                ShowMsg("lat:" + locationInfoMessage.Latitude + " lng:" + locationInfoMessage.Longitude);
                //some model device, these is the code of 8806 plus.
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = personalEncoder.getLocationMsgReply(locationInfoMessage.Imei, true, locationInfoMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = personalEncoder.getLocationMsgReply(locationInfoMessage.Imei, true, locationInfoMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.LocationAlarmMessage)
            {
                LocationAlarmMessage locationAlarmMessage = (LocationAlarmMessage)message;
                ShowMsg("receive location alarm Message imei :" + locationAlarmMessage.Imei + " serial no: " + locationAlarmMessage.SerialNo + " Alarm is : " + locationAlarmMessage.OriginalAlarmCode);
                ShowMsg("lat:" + locationAlarmMessage.Latitude + " lng:" + locationAlarmMessage.Longitude);
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = personalEncoder.getLocationAlarmMsgReply(locationAlarmMessage.Imei, true, locationAlarmMessage.SerialNo, locationAlarmMessage.OriginalAlarmCode);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = personalEncoder.getLocationAlarmMsgReply(locationAlarmMessage.Imei, true, locationAlarmMessage.SerialNo, locationAlarmMessage.OriginalAlarmCode);
                dict[strClientKey].Send(reply);
            }
            else if (message is NetworkInfoMessage)
            {
                NetworkInfoMessage networkInfoMessage = (NetworkInfoMessage)message;
                ShowMsg("receive network info message :" + networkInfoMessage.Imei);
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = personalEncoder.getNetworkMsgReply(networkInfoMessage.Imei, networkInfoMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = personalEncoder.getNetworkMsgReply(networkInfoMessage.Imei, networkInfoMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is WifiMessage)
            {
                WifiMessage wifiMessage = (WifiMessage)message;
                ShowMsg("receive wifi location message :" + wifiMessage.Imei);
                byte[] reply = personalEncoder.getWifiMsgReply(wifiMessage.Imei, wifiMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is ForwardMessage)
            {
                ForwardMessage forwardMessage = (ForwardMessage)message;
                ShowMsg("receive debug message :" + forwardMessage.Imei + " : " + forwardMessage.Content);
            }
            else if (message is USSDMessage)
            {
                USSDMessage ussdMessage = (USSDMessage)message;
                ShowMsg("receive ussd message :" + ussdMessage.Imei + " : " + ussdMessage.Content);
            }
            else if (message is BluetoothPeripheralDataMessage)
            {
                BluetoothPeripheralDataMessage bluetoothPeripheralDataMessage = (BluetoothPeripheralDataMessage)message;
                ShowMsg("receive bluetooth peripheral data message:" + bluetoothPeripheralDataMessage.Imei);
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = personalEncoder.getBluetoothPeripheralMsgReply(bluetoothPeripheralDataMessage.Imei, bluetoothPeripheralDataMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = personalEncoder.getBluetoothPeripheralMsgReply(bluetoothPeripheralDataMessage.Imei, bluetoothPeripheralDataMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
        }
Ejemplo n.º 2
0
        private void DealObdDeviceMessage(TopflytechCodec.Entities.Message message, Socket socket)
        {
            string strClientKey = socket.RemoteEndPoint.ToString();

            if (message is TopflytechCodec.Entities.SignInMessage)
            {
                SignInMessage signInMessage = (SignInMessage)message;
                ShowMsg("receive signIn Message imei :" + signInMessage.Imei + " serial no: " + signInMessage.SerialNo + " firmware :" + signInMessage.Firmware + " software: " + signInMessage.Software + "platform:" + signInMessage.Platform);
                //some  model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getSignInMsgReply(signInMessage.Imei, true, signInMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getSignInMsgReply(signInMessage.Imei, true, signInMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.HeartbeatMessage)
            {
                HeartbeatMessage heartbeatMessage = (HeartbeatMessage)message;
                ShowMsg("receive heartbeat Message imei :" + heartbeatMessage.Imei + " serial no: " + heartbeatMessage.SerialNo);
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getHeartbeatMsgReply(heartbeatMessage.Imei, true, heartbeatMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getHeartbeatMsgReply(heartbeatMessage.Imei, true, heartbeatMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.LocationInfoMessage)
            {
                LocationInfoMessage locationInfoMessage = (LocationInfoMessage)message;
                ShowMsg("receive location Info Message imei :" + locationInfoMessage.Imei + " serial no: " + locationInfoMessage.SerialNo);
                ShowMsg("lat:" + locationInfoMessage.Latitude + " lng:" + locationInfoMessage.Longitude);
                //some model device, these is the code of 8806 plus.
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getLocationMsgReply(locationInfoMessage.Imei, true, locationInfoMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getLocationMsgReply(locationInfoMessage.Imei, true, locationInfoMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.LocationAlarmMessage)
            {
                LocationAlarmMessage locationAlarmMessage = (LocationAlarmMessage)message;
                ShowMsg("receive location alarm Message imei :" + locationAlarmMessage.Imei + " serial no: " + locationAlarmMessage.SerialNo + " Alarm is : " + locationAlarmMessage.OriginalAlarmCode);
                ShowMsg("lat:" + locationAlarmMessage.Latitude + " lng:" + locationAlarmMessage.Longitude);
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getLocationAlarmMsgReply(locationAlarmMessage.Imei, true, locationAlarmMessage.SerialNo, locationAlarmMessage.OriginalAlarmCode);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getLocationAlarmMsgReply(locationAlarmMessage.Imei, true, locationAlarmMessage.SerialNo, locationAlarmMessage.OriginalAlarmCode);
                dict[strClientKey].Send(reply);
            }
            else if (message is GpsDriverBehaviorMessage)
            {
                GpsDriverBehaviorMessage gpsDriverBehaviorMessage = (GpsDriverBehaviorMessage)message;
                ShowMsg("receive gps driver behavior message :" + gpsDriverBehaviorMessage.Imei);
                ShowMsg("behavior is :" + getGpsDriverBehaviorDescription(gpsDriverBehaviorMessage.BehaviorType));
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getGpsDriverBehaviorMsgReply(gpsDriverBehaviorMessage.Imei, gpsDriverBehaviorMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getGpsDriverBehaviorMsgReply(gpsDriverBehaviorMessage.Imei, gpsDriverBehaviorMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.ConfigMessage)
            {
                ConfigMessage configMessage = (ConfigMessage)message;
                ShowMsg("receive config Message imei :" + configMessage.Imei + " serial no: " + configMessage.SerialNo + " config Content:" + configMessage.ConfigResultContent);
            }
            else if (message is TopflytechCodec.Entities.AccelerationDriverBehaviorMessage)
            {
                AccelerationDriverBehaviorMessage accelerationDriverBehaviorMessage = (AccelerationDriverBehaviorMessage)message;
                ShowMsg("receive acceleration driver behavior message :" + accelerationDriverBehaviorMessage.Imei);
                ShowMsg("behavior is :" + getGpsDriverBehaviorDescription(accelerationDriverBehaviorMessage.BehaviorType));
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getAccelerationDriverBehaviorMsgReply(accelerationDriverBehaviorMessage.Imei, accelerationDriverBehaviorMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getAccelerationDriverBehaviorMsgReply(accelerationDriverBehaviorMessage.Imei, accelerationDriverBehaviorMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is TopflytechCodec.Entities.AccidentAccelerationMessage)
            {
                AccidentAccelerationMessage accidentAccelerationMessage = (AccidentAccelerationMessage)message;
                ShowMsg("receive accident acceleration message :" + accidentAccelerationMessage.Imei);
                //some model device,need serial no,reply this message
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getAccelerationAlarmMsgReply(accidentAccelerationMessage.Imei, accidentAccelerationMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getAccelerationAlarmMsgReply(accidentAccelerationMessage.Imei, accidentAccelerationMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is BluetoothPeripheralDataMessage)
            {
                BluetoothPeripheralDataMessage bluetoothPeripheralDataMessage = (BluetoothPeripheralDataMessage)message;
                ShowMsg("receive bluetooth peripheral data message:" + bluetoothPeripheralDataMessage.Imei);
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getBluetoothPeripheralMsgReply(bluetoothPeripheralDataMessage.Imei, bluetoothPeripheralDataMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getBluetoothPeripheralMsgReply(bluetoothPeripheralDataMessage.Imei, bluetoothPeripheralDataMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is NetworkInfoMessage)
            {
                NetworkInfoMessage networkInfoMessage = (NetworkInfoMessage)message;
                ShowMsg("receive network info message :" + networkInfoMessage.Imei);
                //if (message.IsNeedResp)
                //{
                //    byte[] reply = t880xdEncoder.getNetworkMsgReply(networkInfoMessage.Imei, networkInfoMessage.SerialNo);
                //    dict[strClientKey].Send(reply);
                //}
                byte[] reply = t880xdEncoder.getNetworkMsgReply(networkInfoMessage.Imei, networkInfoMessage.SerialNo);
                dict[strClientKey].Send(reply);
            }
            else if (message is ForwardMessage)
            {
                ForwardMessage forwardMessage = (ForwardMessage)message;
                ShowMsg("receive debug message :" + forwardMessage.Imei + " : " + forwardMessage.Content);
            }
            else if (message is USSDMessage)
            {
                USSDMessage ussdMessage = (USSDMessage)message;
                ShowMsg("receive ussd message :" + ussdMessage.Imei + " : " + ussdMessage.Content);
            }
        }