71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace SafeMobileLib.Registration
|
|||
|
{
|
|||
|
public class RegistrationResponse
|
|||
|
{
|
|||
|
private RegistrationCode registrationCode = RegistrationCode.ServerUnreachable;
|
|||
|
public RegistrationCode RegistrationStatus { get { return registrationCode; } }
|
|||
|
|
|||
|
private String appServerVersion;
|
|||
|
public String AppServerVersion { get { return appServerVersion; } }
|
|||
|
|
|||
|
private String messageBusIP;
|
|||
|
public String MessageBusIP { get { return messageBusIP; } }
|
|||
|
|
|||
|
private Int16 messageBusPort;
|
|||
|
public Int16 MessageBusPort { get { return messageBusPort; } }
|
|||
|
|
|||
|
private String dataBaseServerIP;
|
|||
|
public String DataBaseServerIP { get { return dataBaseServerIP; } }
|
|||
|
|
|||
|
private String dataBaseName;
|
|||
|
public String DataBaseName { get { return dataBaseName; } }
|
|||
|
|
|||
|
private String dataBaseUser;
|
|||
|
public String DataBaseUser { get { return dataBaseUser; } }
|
|||
|
|
|||
|
private String dataBasePassword;
|
|||
|
public String DataBasePassword { get { return dataBasePassword; } }
|
|||
|
|
|||
|
private Int16 dataBasePort;
|
|||
|
public Int16 DataBasePort { get { return dataBasePort; } }
|
|||
|
|
|||
|
private Int16 voicePort = 17234;
|
|||
|
public Int16 VoicePort { get { return voicePort; } }
|
|||
|
|
|||
|
public RegistrationResponse(String registrationResponse)
|
|||
|
{
|
|||
|
// split the resonse on ;
|
|||
|
String[] options = registrationResponse.Split(new char[] { ';'}, StringSplitOptions.RemoveEmptyEntries);
|
|||
|
|
|||
|
// message is not well formatted
|
|||
|
if (options.Length < 1)
|
|||
|
return;
|
|||
|
|
|||
|
if (options[0].Equals("201") && options.Length > 1)
|
|||
|
{
|
|||
|
registrationCode = options[1].StartsWith("invalid") ? RegistrationCode.Unauthorized : RegistrationCode.Registered;
|
|||
|
|
|||
|
if(registrationCode == RegistrationCode.Registered)
|
|||
|
{
|
|||
|
appServerVersion = options[1].Replace("valid-", "");
|
|||
|
messageBusIP = options[2];
|
|||
|
Int16.TryParse(options[3], out messageBusPort);
|
|||
|
dataBaseServerIP = options[4];
|
|||
|
dataBaseName = options[5];
|
|||
|
dataBaseUser = options[6];
|
|||
|
dataBasePassword = options[7];
|
|||
|
Int16.TryParse(options[8], out dataBasePort);
|
|||
|
if(options.Length > 9)
|
|||
|
Int16.TryParse(options[9], out voicePort);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|