Beispiel #1
0
        /// <summary>
        /// Use Protobuf Serialization to serialize objects
        /// </summary>
        /// <returns></returns>
        public static ObjectTransportAssemblyLine UseProtobufSerialization(this ObjectTransportAssemblyLine objectTranposrtAssemblyLine)
        {
            var protobufSerialization = new ProtobufSerializer();

            objectTranposrtAssemblyLine.SetSerializer(protobufSerialization);

            return(objectTranposrtAssemblyLine);
        }
Beispiel #2
0
        /// <summary>
        /// Use Json serialization to serialize objects
        /// </summary>
        /// <returns></returns>
        public static ObjectTransportAssemblyLine UseJSONserialization(this ObjectTransportAssemblyLine objectTranposrtAssemblyLine)
        {
            var jsonSerialization = new JSONserializer();

            objectTranposrtAssemblyLine.SetSerializer(jsonSerialization);

            return(objectTranposrtAssemblyLine);
        }
        /// <summary>
        /// Create a TCP server. This network channel only supports reliable communication.
        /// </summary>
        /// <param name="ipAddress">the IP address to start the server on</param>
        /// <param name="port">the port to listen on</param>
        /// <returns></returns>
        public static ObjectTransportAssemblyLine CreateTCPServer(this ObjectTransportFactory o)
        {
            TCPServerChannel server = new TCPServerChannel();
            var assemblyLine        = new ObjectTransportAssemblyLine();

            assemblyLine.SetNetworkChannel(server);
            assemblyLine.SetReliableTransport();

            return(assemblyLine);
        }
        /// <summary>
        /// Create a UDP client. This supports reliable and unreliable communications. Defaults to unreliable.
        /// </summary>
        /// <param name="ipAddress">the IP address to start the server on</param>
        /// <param name="port">the port to listen on</param>
        /// <returns></returns>
        public static ObjectTransportAssemblyLine CreateUDPClient(this ObjectTransportFactory o, string ipAddress, int port)
        {
            var client       = new UDPClientChannel(ipAddress, port);
            var assemblyLine = new ObjectTransportAssemblyLine();

            assemblyLine.SetNetworkChannel(client);
            assemblyLine.SetUnreliableTransport();

            return(assemblyLine);
        }
        /// <summary>
        /// Create a UDP server. This supports reliable and unreliable communications. Defaults to unreliable.
        /// </summary>
        /// <param name="ipAddress">the IP address to start the server on</param>
        /// <param name="port">the port to listen on</param>
        /// <returns></returns>
        public static ObjectTransportAssemblyLine CreateUDPServer(this ObjectTransportFactory o, string ipAddress, int port)
        {
            UDPServerChannel server = new UDPServerChannel(ipAddress, port, 32);
            var assemblyLine        = new ObjectTransportAssemblyLine();

            assemblyLine.SetNetworkChannel(server);
            assemblyLine.SetUnreliableTransport();

            return(assemblyLine);
        }
        /// <summary>
        /// Create a TCP client. This network channel only supports reliable communication.
        /// </summary>
        /// <param name="ipAddress">the IP address to start the server on</param>
        /// <param name="port">the port to listen on</param>
        /// <returns></returns>
        public static ObjectTransportAssemblyLine CreateTCPClient(this ObjectTransportFactory o)
        {
            TCPClientChannel client = new TCPClientChannel();

            var assemblyLine = new ObjectTransportAssemblyLine();

            assemblyLine.SetNetworkChannel(client);
            assemblyLine.SetReliableTransport();

            return(assemblyLine);
        }