public Client() { dataSerializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); dataProcessors = new List <DataProcessor>(); dataProcessorOptions = new Dictionary <string, string>(); getInfo(); }
/// <summary> /// On load initialise the example /// </summary> public override void ViewDidLoad() { base.ViewDidLoad(); //Subscribe to the keyboard events NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidHideNotification, HandleKeyboardDidHide); NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, HandleKeyboardDidShow); //Remove the keyboard if the screen is tapped var tap = new UITapGestureRecognizer(); tap.AddTarget(() => { this.View.EndEditing(true); }); this.View.AddGestureRecognizer(tap); //Create the chat application instance ChatApplication = new ChatAppiOS(ChatHistory, MessageBox); //Uncomment this line to enable logging //EnableLogging(); //Set the default serializer to Protobuf ChatApplication.Serializer = DPSManager.GetDataSerializer <NetworkCommsDotNet.DPSBase.ProtobufSerializer>(); //Get the initial size of the chat view ChatApplication.OriginalViewSize = ChatView.Frame; //Print out the application usage instructions ChatApplication.PrintUsageInstructions(); //Initialise comms to add the necessary packet handlers ChatApplication.RefreshNetworkCommsConfiguration(); }
private void InitNetworkComms() { _targetClientDaemonConnection = new List <ConnectionInfo>(); _targetManagingSystemConnection = new List <ConnectionInfo>(); DataSerializer dataSerializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); List <DataProcessor> dataProcessors = new List <DataProcessor>(); Dictionary <string, string> dataProcessorOptions = new Dictionary <string, string>(); SendReceiveOptions noCompressionSRO = new SendReceiveOptions(dataSerializer, new List <DataProcessor>(), dataProcessorOptions); //dataProcessors.Add(DPSManager.GetDataProcessor<QuickLZCompressor.QuickLZ>()); dataProcessors.Add(DPSManager.GetDataProcessor <SharpZipLibCompressor.SharpZipLibGzipCompressor>()); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(dataSerializer, dataProcessors, dataProcessorOptions); NetworkComms.DefaultSendReceiveOptions.IncludePacketConstructionTime = true; NetworkComms.DefaultSendReceiveOptions.ReceiveHandlePriority = QueueItemPriority.AboveNormal; List <ConnectionListenerBase> ClientDaemonListenList = Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, 20018)); // listen on 20018 for client daemon List <ConnectionListenerBase> ManagingSystemListenList = Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, 20019)); // listen on 20019 for managing system ClientDaemonListenList.ForEach(x => x.AppendIncomingPacketHandler <VRCommand>("Command", HandleIncomingCommandClientDaemon)); ManagingSystemListenList.ForEach(x => x.AppendIncomingPacketHandler <VRCommandServer>("Command", HandleIncomingCommandManagingSystem)); NetworkComms.AppendGlobalConnectionEstablishHandler(HandleClientConnectionEstablished); NetworkComms.AppendGlobalConnectionCloseHandler(HandleClientConnectionClosed); NetworkComms.ConnectionListenModeUseSync = true; }
private Client() { NetworkComms.DisableLogging(); NetworkComms.IgnoreUnknownPacketTypes = true; var serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); NetworkComms.DefaultSendReceiveOptions.DataProcessors.Add( DPSManager.GetDataProcessor <RijndaelPSKEncrypter>()); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(serializer, NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); RijndaelPSKEncrypter.AddPasswordToOptions(NetworkComms.DefaultSendReceiveOptions.Options, Utility.PSK); NetworkComms.AppendGlobalIncomingPacketHandler <Ping>(Ping.Header, PingHandler); NetworkComms.AppendGlobalIncomingPacketHandler <ClassInfo>(ClassInfo.Header, ClassInfoHandler); NetworkComms.AppendGlobalIncomingPacketHandler <InstructorLogin>(InstructorLogin.Header, InstructorLoginHandler); NetworkComms.AppendGlobalIncomingPacketHandler <ClientInfo>(ClientInfo.Header, ClientInfoHandler); PeerDiscovery.EnableDiscoverable(PeerDiscovery.DiscoveryMethod.UDPBroadcast); PeerDiscovery.OnPeerDiscovered += OnPeerDiscovered; //NetworkComms.AppendGlobalIncomingPacketHandler<byte[]>("PartialFileData", IncomingPartialFileData); //NetworkComms.AppendGlobalIncomingPacketHandler<SendInfo>("PartialFileDataInfo", // IncomingPartialFileDataInfo); //NetworkComms.AppendGlobalConnectionCloseHandler(OnConnectionClose); PeerDiscovery.DiscoverPeersAsync(PeerDiscovery.DiscoveryMethod.UDPBroadcast); }
public ServerForm() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; button1.Click += button1_Click; this.FormClosing += ServerForm_FormClosing; UDPListening(); timer = new System.Timers.Timer { Interval = 100, AutoReset = true }; timer.Elapsed += Timer_Elapsed; timer.Start(); List <DataProcessor> pros = new List <DataProcessor> { DPSManager.GetDataProcessor <RijndaelPSKEncrypter>() }; Dictionary <string, string> options = new Dictionary <string, string> { { "RijndaelPSKEncrypter_PASSWORD", "password" } }; NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer <ProtoSerializer>(), pros, options); //NetworkComms.DefaultSendReceiveOptions.DataProcessors.Add(DPSManager.GetDataProcessor<RijndaelPSKEncrypter>()); //RijndaelPSKEncrypter.AddPasswordToOptions(NetworkComms.DefaultSendReceiveOptions.Options, "password"); }
public void Run() { NetworkComms.AppendGlobalIncomingPacketHandler <string>("Message", PrintIncomingMessage); NetworkComms.AppendGlobalIncomingPacketHandler <Protocol>("Protocol", HandleIncomingProtocol); NetworkComms.AppendGlobalIncomingPacketHandler <HandShake>("HandShake", HandleIncomingHandShake); NetworkComms.AppendGlobalConnectionCloseHandler(HandleConnectionClosed); this.Serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(Serializer, NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, 0)); Console.WriteLine("Server listening for TCP connection on:"); foreach (IPEndPoint l in Connection.ExistingLocalListenEndPoints(ConnectionType.TCP)) { Console.WriteLine("{0}:{1}", l.Address, l.Port); } lastServerIPEndPoint = (IPEndPoint)Connection.ExistingLocalListenEndPoints(ConnectionType.TCP).Last(); while (true) { if (Clients.Count() == 2) { game = new SPoker(Clients.Last(), Clients.First()); game.Start(); } Thread.Sleep(200); } //NetworkComms.Shutdown(); }
// private static bool Emulator; public static void Start() { if (_started) { return; } _started = true; NetworkComms.EnableLogging(new LiteLogger(LiteLogger.LogMode.ConsoleOnly)); NetworkComms.IgnoreUnknownPacketTypes = true; var serializer = DPSManager.GetDataSerializer <NetworkCommsDotNet.DPSBase.ProtobufSerializer>(); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(serializer, NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); NetworkComms.AppendGlobalIncomingPacketHandler <ServerInfo>(ServerInfo.GetHeader(), ServerInfoReceived); PeerDiscovery.EnableDiscoverable(PeerDiscovery.DiscoveryMethod.UDPBroadcast); PeerDiscovery.OnPeerDiscovered += OnPeerDiscovered; Connection.StartListening(ConnectionType.UDP, new IPEndPoint(IPAddress.Any, 0)); PeerDiscovery.DiscoverPeersAsync(PeerDiscovery.DiscoveryMethod.UDPBroadcast); }
private void InitNetworkComms() { DataSerializer dataSerializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); List <DataProcessor> dataProcessors = new List <DataProcessor>(); Dictionary <string, string> dataProcessorOptions = new Dictionary <string, string>(); dataProcessors.Add(DPSManager.GetDataProcessor <SharpZipLibCompressor.SharpZipLibGzipCompressor>()); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(dataSerializer, dataProcessors, dataProcessorOptions); NetworkComms.DefaultSendReceiveOptions.IncludePacketConstructionTime = true; NetworkComms.DefaultSendReceiveOptions.ReceiveHandlePriority = QueueItemPriority.AboveNormal; List <ConnectionListenerBase> GameSelectorUIListenList = Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Loopback, 20015)); // listen on 20015 for local UI client List <ConnectionListenerBase> DashboardListenList = Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Loopback, 20016)); // listen on 20016 for local Dashboard client GameSelectorUIListenList.ForEach(x => x.AppendIncomingPacketHandler <VRCommand>("Command", HandleIncomingCommandClientUI)); DashboardListenList.ForEach(x => x.AppendIncomingPacketHandler <VRCommand>("Command", HandleIncomingCommandDashboard)); NetworkComms.AppendGlobalConnectionEstablishHandler(HandleGlobalConnectionEstablished); NetworkComms.AppendGlobalConnectionCloseHandler(HandleGlobalConnectionClosed); IPEndPoint ip = IPTools.ParseEndPointFromString(Utility.GetCoreConfig("ServerIPPort")); _targetServerConnectionInfo = new ConnectionInfo(ip, ApplicationLayerProtocolStatus.Enabled); }
private void InitConnection() { string serverAddress; DataSerializer dataSerializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); List <DataProcessor> dataProcessors = new List <DataProcessor>(); Dictionary <string, string> dataProcessorOptions = new Dictionary <string, string>(); dataProcessors.Add(DPSManager.GetDataProcessor <SharpZipLibCompressor.SharpZipLibGzipCompressor>()); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(dataSerializer, dataProcessors, dataProcessorOptions); NetworkComms.DefaultSendReceiveOptions.IncludePacketConstructionTime = true; NetworkComms.DefaultSendReceiveOptions.ReceiveHandlePriority = QueueItemPriority.AboveNormal; if (IsMainThread) { NetworkComms.AppendGlobalIncomingPacketHandler <VRCommand>("Command", HandleIncomingCommand); } SystemConfigs.TryGetValue("ServerIPPort", out serverAddress); // get IP:Port IPEndPoint ip = IPTools.ParseEndPointFromString(serverAddress); targetServerConnectionInfo = new ConnectionInfo(ip, ApplicationLayerProtocolStatus.Enabled); }
public Server() { users = new Dictionary <Connection, ConnectedUser>(); authentication = new PacketHandling.Authentication(this); addNewContact = new PacketHandling.AddNewContact(this); addNewContactResponse = new PacketHandling.AddNewContactResponse(this); personalUserUpdate = new PacketHandling.PersonalUserUpdate(this); deleteAndBlockContact = new PacketHandling.DeleteAndBlockContact(this); transferMessage = new PacketHandling.TransferMessage(this); transferNudge = new PacketHandling.TransferNudge(this); transferWritingStatus = new PacketHandling.TransferWritingStatus(this); accountManager = new AccountManager(); NetworkComms.AppendGlobalConnectionCloseHandler(HandleConnectionClosed); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer <ProtobufSerializer>(), NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); if (!NetworkComms.DefaultSendReceiveOptions.DataProcessors.Contains(DPSManager.GetDataProcessor <RijndaelPSKEncrypter>())) { RijndaelPSKEncrypter.AddPasswordToOptions(NetworkComms.DefaultSendReceiveOptions.Options, Config.Properties.SERVER_ENCRYPTION_KEY); NetworkComms.DefaultSendReceiveOptions.DataProcessors.Add(DPSManager.GetDataProcessor <RijndaelPSKEncrypter>()); } NetworkComms.Shutdown(); Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, Config.Properties.SERVER_PORT)); foreach (IPEndPoint listenEndPoint in Connection.ExistingLocalListenEndPoints(ConnectionType.TCP)) { Program.WriteToConsole("Local End Point: " + listenEndPoint.Address + ":" + listenEndPoint.Port); } BroadCastContacts(Config.Properties.BROADCAST_INTERVAL); }
private static void InitNetworkComms() { DataSerializer dataSerializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); List <DataProcessor> dataProcessors = new List <DataProcessor>(); Dictionary <string, string> dataProcessorOptions = new Dictionary <string, string>(); dataProcessors.Add(DPSManager.GetDataProcessor <SharpZipLibCompressor.SharpZipLibGzipCompressor>()); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(dataSerializer, dataProcessors, dataProcessorOptions); NetworkComms.DefaultSendReceiveOptions.IncludePacketConstructionTime = true; NetworkComms.DefaultSendReceiveOptions.ReceiveHandlePriority = QueueItemPriority.AboveNormal; NetworkComms.AppendGlobalIncomingPacketHandler <VRCommandServer>("Command", HandleGlobalIncomingCommand); NetworkComms.AppendGlobalConnectionEstablishHandler(HandleGlobalConnectionEstablishEvent); NetworkComms.AppendGlobalConnectionCloseHandler(HandleGlobalConnectionCloseEvent); IPEndPoint ip = IPTools.ParseEndPointFromString(Utility.GetCoreConfig("ServerIPPort")); _targetServerConnectionInfo = new ConnectionInfo(ip, ApplicationLayerProtocolStatus.Enabled); _timerPing = new System.Timers.Timer(); _timerPing.Elapsed += new ElapsedEventHandler(OnTimerPingEvent); _timerPing.Interval = 3000; _timerPing.Enabled = true; }
public void Connect(IPAddress address) { NetworkComms.RemoveGlobalConnectionCloseHandler(HandleConnectionClosed); NetworkComms.Shutdown(); connectionInfo = new ConnectionInfo(address.ToString(), port); if (!packetsAppended) { NetworkComms.AppendGlobalIncomingPacketHandler <Custom>("Custom", ReceiveCustomPacket); NetworkComms.AppendGlobalIncomingPacketHandler <int>(PacketName.ReSessionVerificationResult.ToString(), SessionVerificationResultReceived); NetworkComms.AppendGlobalIncomingPacketHandler <string>(PacketName.ReSessionId.ToString(), SessionIdReceived); NetworkComms.AppendGlobalIncomingPacketHandler <int>(PacketName.ReLoginResult.ToString(), ReceiveLoginResult); NetworkComms.AppendGlobalIncomingPacketHandler <ModuleList>(PacketName.ReModuleList.ToString(), ModuleList); NetworkComms.AppendGlobalIncomingPacketHandler <AppFileData>(PacketName.ReAppFile.ToString(), AppFile); NetworkComms.AppendGlobalIncomingPacketHandler <GroupList>(PacketName.ReUserGroupList.ToString(), GroupListReceived); NetworkComms.AppendGlobalIncomingPacketHandler <int>(PacketName.ReUnauthorized.ToString(), UnAuthorizedReceived); packetsAppended = true; } NetworkComms.AppendGlobalConnectionCloseHandler(HandleConnectionClosed); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer <ProtobufSerializer>(), NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); }
public void Start() { //NetworkCommsDotNet.DPSBase.RijndaelPSKEncrypter.AddPasswordToOptions(NetworkComms.DefaultSendReceiveOptions.Options, "_MASSIVE123"); Log("Encryption active", 2); DataSerializer dataSerializer = DPSManager.GetDataSerializer <ProtobufSerializer>();; Log("Data SerializeR:" + dataSerializer.ToString(), UTILITY); List <DataProcessor> dataProcessors = new List <DataProcessor>(); //dataProcessors.Add(DPSManager.GetDataProcessor<QuickLZ>()); NetworkComms.AppendGlobalConnectionEstablishHandler(HandleConnection); NetworkComms.AppendGlobalIncomingPacketHandler <string>("Message", MessageReceived); NetworkComms.AppendGlobalConnectionCloseHandler(HandleConnectionClosed); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(dataSerializer, NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); IPAddress ip = IPAddress.Parse(ServerIPAddress); Connection.StartListening(ConnectionType.TCP, new System.Net.IPEndPoint(ip, ServerPort)); Log("Listening for TCP messages on:", UTILITY); foreach (System.Net.IPEndPoint localEndPoint in Connection.ExistingLocalListenEndPoints(ConnectionType.TCP)) { Log(localEndPoint.Address + ":" + localEndPoint.Port.ToString(), UTILITY); } Log("Data Directory is:" + Path.Combine(Directory.GetCurrentDirectory(), "data"), UTILITY); MExternalIPSniffer.SniffIP(); }
/// <summary> /// Constructor for the WP8 chat app. /// </summary> public ChatAppWP8(TextBox currentMessageInputBox, TextBlock chatHistory, ScrollViewer chatHistoryScroller) : base("WinPhone8", ConnectionType.TCP) { this.CurrentMessageInputBox = currentMessageInputBox; this.ChatHistory = chatHistory; this.ChatHistoryScroller = chatHistoryScroller; this.Serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); }
/// <summary> /// Constructor for the Android chat app. /// </summary> public ChatAppAndroid(Context parentContext, TextView chatHistory, AutoCompleteTextView input) : base("Android", ConnectionType.TCP) { this.ParentContext = parentContext; this.ChatHistory = chatHistory; this.Input = input; Serializer = DPSManager.GetDataSerializer <NetworkCommsDotNet.DPSBase.ProtobufSerializer>(); }
/// <summary> /// Configure connection settings and register packet handlers. /// </summary> public static void Initialize() { ConnectionInfo = new ConnectionInfo(IpAddress, port); NetworkComms.AppendGlobalIncomingPacketHandler <ModuleList>( PacketName.ReModuleList.ToString(), ModuleList); NetworkComms.AppendGlobalIncomingPacketHandler <ModuleList>( PacketName.ReAllAppList.ToString(), AppList); NetworkComms.AppendGlobalIncomingPacketHandler <int>( PacketName.ReLoginResult.ToString(), LoginResult); NetworkComms.AppendGlobalIncomingPacketHandler <ServiceCommand>( PacketName.ReServiceResponse.ToString(), ServiceResponse); NetworkComms.AppendGlobalIncomingPacketHandler <ServiceLogList>( PacketName.ReServiceLog.ToString(), ServiceLog); NetworkComms.AppendGlobalIncomingPacketHandler <int>( PacketName.ReRegisterAccount.ToString(), RegisterAccount); NetworkComms.AppendGlobalIncomingPacketHandler <AccountList>( PacketName.ReAccountList.ToString(), AccountListReceived); NetworkComms.AppendGlobalIncomingPacketHandler <GroupList>( PacketName.ReUserGroupList.ToString(), GroupListReceived); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReUpdateAccountInformation.ToString(), AccountInformationResponse); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReUpdatePassword.ToString(), PasswordChangeResponse); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReDeleteGroupFromUser.ToString(), DeleteGroupFromUserResponse); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReAddGroupToUser.ToString(), AddGroupToUserReceived); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReDeleteAccount.ToString(), DeleteAccount); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReDeleteGroup.ToString(), DeleteGroup); NetworkComms.AppendGlobalIncomingPacketHandler <GenericResponse>( PacketName.ReAddGroup.ToString(), AddGroup); NetworkComms.AppendGlobalIncomingPacketHandler <GroupList>( PacketName.ReAppGroupList.ToString(), AppGroupList); NetworkComms.AppendGlobalIncomingPacketHandler <int>( PacketName.ReUnauthorized.ToString(), UnAuthorized); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer <ProtobufSerializer>(), NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); }
public void SetSendReceiveOptions() { serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); dataProcessors.Add(DPSManager.GetDataProcessor <SharpZipLibGzipCompressor>()); dataProcessorOptions = new Dictionary <string, string>(); options = new SendReceiveOptions(serializer, dataProcessors, dataProcessorOptions); NetworkComms.DefaultSendReceiveOptions = options; }
/// <summary> /// Start listening on port. /// </summary> public void Start() { NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer <ProtobufSerializer>(), NetworkComms.DefaultSendReceiveOptions.DataProcessors, NetworkComms.DefaultSendReceiveOptions.Options); NetworkComms.Shutdown(); Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, port)); }
public void LoadCardsArray(string fileLocation) { //cardsArray = (byte[][])SerializeObject.Load(fileLocation); //cardsArray = FBPSerialiser.DeserialiseDataObject<byte[][]>(File.ReadAllBytes(fileLocation)); cardsArray = DPSManager.GetDataSerializer <ProtobufSerializer>().DeserialiseDataObject <byte[][]>(File.ReadAllBytes(fileLocation), new List <DataProcessor>() { cardsCompressor }, new Dictionary <string, string>()); }
/// <summary> /// Constructor for the WPF chat app. /// </summary> public ChatAppWPF(TextBlock chatHistory, ScrollViewer scroller, TextBox messagesFrom, TextBox messagesText) : base(HostInfo.HostName, ConnectionType.TCP) { this.ChatHistory = chatHistory; this.Scroller = scroller; this.MessagesFrom = messagesFrom; this.MessagesText = messagesText; this.Serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); }
/// <summary> /// Serialise the current cache and return a byte array /// </summary> /// <returns></returns> public byte[] Serialise() { byte[] returnArray; startRead(); returnArray = DPSManager.GetDataSerializer <ProtobufSerializer>().SerialiseDataObject <databaseCache>(this).ThreadSafeStream.ToArray(); endRead(); return(returnArray); }
public GVApp(TextBox txtbIP, TextBox txtbPort, TextBox txtbValue, Button btnAdd, Button btnSend, GridControl gridctr) : base(HostInfo.HostName, ConnectionType.TCP) { this.txtbIP = txtbIP; this.txtbPort = txtbPort; this.txtbValue = txtbValue; this.btnAdd = btnAdd; this.btnSend = btnSend; this.gridctr = gridctr; this.Serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); }
public GNApp(TextBox txtbIP, TextBox txtbPort, TextBox txtbClientPort, TextBox txtbReceive, TextBox txtbSend, ComboBox cmbbSend) : base(HostInfo.HostName, ConnectionType.TCP) { this.txtbIP = txtbIP; this.txtbPort = txtbPort; this.txtbClientPort = txtbClientPort; this.txtbReceive = txtbReceive; this.txtbSend = txtbSend; this.cmbbSend = cmbbSend; this.Serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); }
/// <summary> /// Saves the current GATracker to disk at the provided location. /// </summary> /// <param name="saveLocation"></param> /// <param name="includeLogFile">If true also saves out a human readable log file</param> public void Save(string saveLocation, bool includeLogFile) { lock (locker) { File.WriteAllBytes(saveLocation + "\\GATracker.gat", DPSManager.GetDataSerializer <ProtobufSerializer>().SerialiseDataObject <GATracker>(this).ThreadSafeStream.ToArray()); if (includeLogFile) { WriteOutLogFile(saveLocation); } } }
private void SerializationMethod_Checked(object sender, RoutedEventArgs e) { if ((sender as RadioButton).Content.ToString() == "Protobuf" && (bool)(sender as RadioButton).IsChecked) { (App.Current as App).ChatApplication.Serializer = DPSManager.GetDataSerializer <ProtobufSerializer>(); } else { (App.Current as App).ChatApplication.Serializer = DPSManager.GetDataSerializer <JSONSerializer>(); } }
private void EstablishConnection() { dataSerializer = DPSManager.GetDataSerializer <JSONSerializer>(); SelectDataProcessors(out dataProcessors, out dataProcessorOptions); NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions(dataSerializer, dataProcessors, dataProcessorOptions); connectionInfo = new ConnectionInfo("127.0.0.1", 8080); newTCPConnection = TCPConnection.GetConnection(connectionInfo); }
/// <summary> /// Create a new listener instance /// </summary> /// <param name="connectionType">The connection type to listen for.</param> /// <param name="sendReceiveOptions">The send receive options to use for this listener</param> /// <param name="applicationLayerProtocol">If enabled NetworkComms.Net uses a custom /// application layer protocol to provide useful features such as inline serialisation, /// transparent packet transmission, remote peer handshake and information etc. We strongly /// recommend you enable the NetworkComms.Net application layer protocol.</param> /// <param name="allowDiscoverable">Determines if the newly created <see cref="ConnectionListenerBase"/> will be discoverable if <see cref="Tools.PeerDiscovery"/> is enabled.</param> protected ConnectionListenerBase(ConnectionType connectionType, SendReceiveOptions sendReceiveOptions, ApplicationLayerProtocolStatus applicationLayerProtocol, bool allowDiscoverable) { if (connectionType == ConnectionType.Undefined) { throw new ArgumentException("ConnectionType.Undefined is not valid when calling this method.", "connectionType"); } if (sendReceiveOptions == null) { throw new ArgumentNullException("sendReceiveOptions", "Provided send receive option may not be null."); } if (applicationLayerProtocol == ApplicationLayerProtocolStatus.Undefined) { throw new ArgumentException("ApplicationLayerProtocolStatus.Undefined is not valid when calling this method.", "applicationLayerProtocol"); } //Validate SRO options if the application layer protocol is disabled if (applicationLayerProtocol == ApplicationLayerProtocolStatus.Disabled) { if (sendReceiveOptions.Options.ContainsKey("ReceiveConfirmationRequired")) { throw new ArgumentException("Attempted to create an unmanaged connection when the provided send receive" + " options specified the ReceiveConfirmationRequired option. Please provide compatible send receive options in order to successfully" + " instantiate this unmanaged connection.", "sendReceiveOptions"); } if (sendReceiveOptions.DataSerializer != DPSManager.GetDataSerializer <NullSerializer>()) { throw new ArgumentException("Attempted to create an unmanaged connection when the provided send receive" + " options serialiser was not NullSerializer. Please provide compatible send receive options in order to successfully" + " instantiate this unmanaged connection.", "sendReceiveOptions"); } if (sendReceiveOptions.DataProcessors.Count > 0) { throw new ArgumentException("Attempted to create an unmanaged connection when the provided send receive" + " options contains data processors. Data processors may not be used with unmanaged connections." + " Please provide compatible send receive options in order to successfully instantiate this unmanaged connection.", "sendReceiveOptions"); } } if (NetworkComms.LoggingEnabled) { NetworkComms.Logger.Info("Created new connection listener (" + connectionType.ToString() + "-" + (applicationLayerProtocol == ApplicationLayerProtocolStatus.Enabled ? "E" : "D") + ")."); } this.ConnectionType = connectionType; this.ListenerDefaultSendReceiveOptions = sendReceiveOptions; this.ApplicationLayerProtocol = applicationLayerProtocol; this.IsDiscoverable = allowDiscoverable; }
public static GATracker Load(string loadLocation) { try { return(DPSManager.GetDataSerializer <ProtobufSerializer>().DeserialiseDataObject <GATracker>(File.ReadAllBytes(Path.Combine(loadLocation, "GATracker.gat")))); } catch (Exception) { //If there is an exception we just return a blank tracker return(new GATracker()); } }
private void UseJSON_Checked(object sender, RoutedEventArgs e) { if (this.UseProtobuf != null && this.UseProtobuf.IsChecked != null && !(bool)this.UseProtobuf.IsChecked) { //Update the application and connectionType this.UseProtobuf.IsChecked = false; this.UseJSON.IsChecked = true; chatApplication.Serializer = DPSManager.GetDataSerializer <JSONSerializer>(); chatApplication.RefreshNetworkCommsConfiguration(); chatApplication.AppendLineToChatHistory("Serializer changed to JSON serializer."); } }
/// <summary> /// Toggle encryption /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UseEncryptionBox_CheckedToggle(object sender, RoutedEventArgs e) { if (useEncryptionBox.IsChecked != null && (bool)useEncryptionBox.IsChecked) { RijndaelPSKEncrypter.AddPasswordToOptions(NetworkComms.DefaultSendReceiveOptions.Options, encryptionKey); NetworkComms.DefaultSendReceiveOptions.DataProcessors.Add(DPSManager.GetDataProcessor <RijndaelPSKEncrypter>()); } else { NetworkComms.DefaultSendReceiveOptions.DataProcessors.Remove(DPSManager.GetDataProcessor <RijndaelPSKEncrypter>()); } }