public OutboundRabbitMqTransport(IRabbitMqEndpointAddress address,
     ConnectionHandler<RabbitMqConnection> connectionHandler, bool bindToQueue)
 {
     _address = address;
     _connectionHandler = connectionHandler;
     _bindToQueue = bindToQueue;
 }
 public InboundRabbitMqTransport(IRabbitMqEndpointAddress address,
                                 ConnectionHandler<RabbitMqConnection> connectionHandler,
                                 bool purgeExistingMessages)
 {
     _address = address;
     _connectionHandler = connectionHandler;
     _purgeExistingMessages = purgeExistingMessages;
 }
 public TransactionalInboundMsmqTransport(IMsmqEndpointAddress address,
                                          ConnectionHandler<MessageQueueConnection> connectionHandler,
                                          TimeSpan transactionTimeout,
                                          IsolationLevel isolationLevel)
     : base(address, connectionHandler)
 {
     _transactionTimeout = transactionTimeout;
     _isolationLevel = isolationLevel;
 }
        /// <summary>
        /// 	c'tor
        /// </summary>
        public OutboundAzureServiceBusTransport( IAzureServiceBusEndpointAddress address,  ConnectionHandler<AzureServiceBusConnection> connectionHandler, IOutboundSettings outboundSettings)
        {
            if (address == null)
                throw new ArgumentNullException("address");
            if (connectionHandler == null)
                throw new ArgumentNullException("connectionHandler");

            _connectionHandler = connectionHandler;
            _address = address;

            _logger.DebugFormat("created outbound transport for address '{0}'", address);
        }
    void Start()
    {
        if(_myNetworkIdentity.isServer)
        {
            _connectionHandler = GameObject.FindGameObjectWithTag(Tags.CONNECTIONHANDLER).GetComponent<ConnectionHandler>();
            _connectionHandler.OnPlayerAdded +=  RefreshPlayerControllers;

            GameObject[] spawnpoints = GameObject.FindGameObjectsWithTag(Tags.SPAWNPOINT);
            foreach (var item in spawnpoints)
            {
                _spawnPositions.Add(item.transform.position);
            }
            RefreshPlayerControllers();
        }
    }
		/// <summary>
		/// 	c'tor
		/// </summary>
		public OutboundTransportImpl(
			[NotNull] AzureServiceBusEndpointAddress address,
			[NotNull] ConnectionHandler<ConnectionImpl> connectionHandler, 
			[NotNull] SenderSettings settings)
		{
			if (address == null) throw new ArgumentNullException("address");
			if (connectionHandler == null) throw new ArgumentNullException("connectionHandler");
			if (settings == null) throw new ArgumentNullException("settings");

			_connectionHandler = connectionHandler;
			_settings = settings;
			_address = address;

			_logger.DebugFormat("created outbound transport for address '{0}'", address);
		}
        public InboundAzureServiceBusTransport(IAzureServiceBusEndpointAddress address,
            ConnectionHandler<AzureServiceBusConnection> connectionHandler,
            IMessageNameFormatter formatter = null,
            IInboundSettings inboundSettings = null)
        {
            if (address == null)
                throw new ArgumentNullException("address");
            if (connectionHandler == null)
                throw new ArgumentNullException("connectionHandler");

            _address = address;
            _connectionHandler = connectionHandler;
            _formatter = formatter ?? new AzureServiceBusMessageNameFormatter();
            _inboundSettings = inboundSettings;

            _logger.DebugFormat("created new inbound transport for '{0}'", address);
        }
		public InboundTransportImpl([NotNull] AzureServiceBusEndpointAddress address,
			[NotNull] ConnectionHandler<ConnectionImpl> connectionHandler,
			[NotNull] AzureManagement management, 
			[CanBeNull] IMessageNameFormatter formatter = null,
			[CanBeNull] ReceiverSettings receiverSettings = null)
		{
			if (address == null) throw new ArgumentNullException("address");
			if (connectionHandler == null) throw new ArgumentNullException("connectionHandler");
			if (management == null) throw new ArgumentNullException("management");

			_address = address;
			_connectionHandler = connectionHandler;
			_management = management;
			_formatter = formatter ?? new AzureMessageNameFormatter();
			_receiverSettings = receiverSettings; // can be null all the way to usage in Receiver.

			_logger.DebugFormat("created new inbound transport for '{0}'", address);
		}
Example #9
0
 public void updaterequestordetails(long requestorId, string firstname, string lastname, string gender, long age, long contactno, string emailid, string description)
 {
     using (SqlConnection connect = ConnectionHandler.getConnection())
     {
         if (description == " ")
         {
             description = null;
             connect.Open();
             SqlCommand cmd = new SqlCommand("update requestor set  first_name =@firstname , last_name = @lastname, gender =@Gender, age=@age, contact_no = @contactno, emailId = @emailid ,description=@description where requestorId = @requestorid", connect);
             cmd.Parameters.AddWithValue("@requestorid", requestorId);
             cmd.Parameters.AddWithValue("@firstname", firstname);
             cmd.Parameters.AddWithValue("@lastname", lastname);
             cmd.Parameters.AddWithValue("@Gender", gender);
             cmd.Parameters.AddWithValue("@age", age);
             cmd.Parameters.AddWithValue("@contactno", contactno);
             cmd.Parameters.AddWithValue("@emailid", emailid);
             cmd.Parameters.AddWithValue("@description", description);
             cmd.ExecuteNonQuery();
             connect.Close();
         }
         else
         {
             connect.Open();
             SqlCommand cmd = new SqlCommand("update requestor set  first_name =@firstname , last_name = @lastname, gender =@Gender, age=@age, contact_no = @contactno, emailId = @emailid ,description=@description where requestorId = @requestorid", connect);
             cmd.Parameters.AddWithValue("@requestorid", requestorId);
             cmd.Parameters.AddWithValue("@firstname", firstname);
             cmd.Parameters.AddWithValue("@lastname", lastname);
             cmd.Parameters.AddWithValue("@Gender", gender);
             cmd.Parameters.AddWithValue("@age", age);
             cmd.Parameters.AddWithValue("@contactno", contactno);
             cmd.Parameters.AddWithValue("@emailid", emailid);
             cmd.Parameters.AddWithValue("@description", description);
             cmd.ExecuteNonQuery();
             connect.Close();
         }
     }
 }
        public async Task GetAmqpAuthenticationTest()
        {
            // Arrange
            var identity          = Mock.Of <IIdentity>(i => i.Id == "d1/m1");
            var clientCredentials = Mock.Of <IClientCredentials>(c => c.Identity == identity);
            var deviceListener    = Mock.Of <IDeviceListener>();

            Mock.Get(deviceListener).Setup(d => d.BindDeviceProxy(It.IsAny <IDeviceProxy>()));

            var connectionProvider = Mock.Of <IConnectionProvider>(c => c.GetDeviceListenerAsync(clientCredentials) == Task.FromResult(deviceListener));

            var amqpAuthentication = new AmqpAuthentication(true, Option.Some(clientCredentials));
            var cbsNode            = Mock.Of <ICbsNode>(c => c.GetAmqpAuthentication() == Task.FromResult(amqpAuthentication));
            var amqpConnection     = Mock.Of <IAmqpConnection>(c => c.FindExtension <ICbsNode>() == cbsNode);
            var connectionHandler  = new ConnectionHandler(amqpConnection, connectionProvider);

            // Act
            var tasks = new List <Task <AmqpAuthentication> >();

            for (int i = 0; i < 10; i++)
            {
                tasks.Add(connectionHandler.GetAmqpAuthentication());
            }
            IList <AmqpAuthentication> amqpAuthentications = (await Task.WhenAll(tasks)).ToList();

            // Assert
            Assert.NotNull(amqpAuthentications);
            Assert.Equal(10, amqpAuthentications.Count);
            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(amqpAuthentication, amqpAuthentications[0]);
            }
            Assert.True(amqpAuthentications[0].IsAuthenticated);
            Assert.Equal(identity, amqpAuthentications[0].ClientCredentials.OrDefault().Identity);
            Mock.Get(connectionProvider).Verify(c => c.GetDeviceListenerAsync(It.IsAny <IClientCredentials>()), Times.AtMostOnce);
            Mock.Get(cbsNode).Verify(d => d.GetAmqpAuthentication(), Times.AtMostOnce);
        }
        public async Task ShouldSendUpdateToGroup_WhenClientConnectionDiesUnexpectedly(
            [Frozen] Mock <IConnectionInitializer> initializer,
            [Frozen] Mock <IConnection> connection,
            [Frozen] Mock <IConnectedClientStore> store,
            [Frozen] Mock <IUpdateDetector> updateDetector,
            [Frozen] Mock <IUpdater> updater,
            ConnectedClient client,
            ConnectedClient anotherClient,
            ConnectionHandler sut)
        {
            connection.Setup(x => x.ReceiveAsync(Cts.Token))
            .ThrowsAsync(Create <Exception>());

            initializer.Setup(x => x.ConnectAsync(It.IsAny <IConnection>(), Cts.Token))
            .ReturnsAsync(client);

            var anotherGroup = Create <string>();
            var popGroups    = new HashSet <string> {
                anotherGroup
            };

            store.Setup(x => x.FindInGroups(It.Is <IEnumerable <string> >(
                                                y => y.Count() == 2 &&
                                                y.Contains(anotherGroup) &&
                                                y.Contains(client.Group))))
            .Returns(new[] { client, anotherClient });

            updateDetector.Setup(x => x.MarkForUpdate(It.IsAny <string>()))
            .Callback <string>(group => popGroups.Add(group));
            updateDetector.Setup(x => x.PopMarked())
            .Returns(popGroups);

            try { await sut.HandleAsync(connection.Object, Cts.Token); } catch { }

            updater.Verify(x => x.SendUpdateAsync(client, Cts.Token), Times.Exactly(2));
            updater.Verify(x => x.SendUpdateAsync(anotherClient, Cts.Token), Times.Exactly(2));
        }
Example #12
0
        public long smedet(string userid)
        {
            model.SME     details = new model.SME();
            SqlConnection connect = ConnectionHandler.getConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select * from sme where userid=@userid", connect);

            cmd.Parameters.AddWithValue("@userid", userid);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            connect.Close();
            DataTable dt = ds.Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                details.SmeId = long.Parse(dr["smeId"].ToString());
            }
            long h = details.SmeId;

            return(h);
        }
Example #13
0
 public void addSmeNomination(long requestId, long smeId)
 {
     using (SqlConnection connection = ConnectionHandler.getConnection())
     {
         int check      = 0;
         int nomination = 0;
         connection.Open();
         SqlCommand cmd = new SqlCommand("select Count(smeNominationId) from smeNomination where requestId=@requestId and sme_Id=@smeId", connection);
         cmd.Parameters.AddWithValue("@smeId", smeId);
         cmd.Parameters.AddWithValue("@requestId", requestId);
         check = int.Parse(cmd.ExecuteScalar().ToString());
         SqlCommand nominations = new SqlCommand("select count(smeNominationId) from smeNomination where sme_Id=@smeId", connection);
         nominations.Parameters.AddWithValue("@smeId", smeId);
         nomination = int.Parse(nominations.ExecuteScalar().ToString());
         if (check == 0)
         {
             SqlCommand addNomination = new SqlCommand("insert into smeNomination values(@requestId,@smeId)", connection);
             addNomination.Parameters.AddWithValue("@requestId", requestId);
             addNomination.Parameters.AddWithValue("@smeId", smeId);
             addNomination.ExecuteNonQuery();
         }
         connection.Close();
     }
 }
Example #14
0
        public List <Trainer> getSearchByDate(string name, DateTime date1, DateTime date2)
        {
            using (SqlConnection connect = ConnectionHandler.getConnection())
            {
                List <Trainer> trainerSearch = new List <Trainer>();
                connect.Open();
                SqlCommand cmd = new SqlCommand("select * from trainer t join trainerAvailability ts on t.trainerId=ts.trainer_id join trainer_skills tss on t.trainerId = tss.trainer_Id join skillset s on tss.skillid = s.skill_id where ts.startdate <=@date1 and ts.enddate >= @date2 and ts.availability_status = 'Available' and s.skill_name = @skill_name", connect);
                cmd.Parameters.AddWithValue("@skill_name", name);
                cmd.Parameters.AddWithValue("@date1", date1.ToShortDateString());
                cmd.Parameters.AddWithValue("@date2", date2.ToShortDateString());
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet        ds = new DataSet();
                da.Fill(ds);
                connect.Close();
                DataTable dt = ds.Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    // sk.Add(dr["skill"].ToString());
                    trainerSearch.Add(new Trainer((long.Parse(dr["trainerId"].ToString())), dr["first_name"].ToString(), dr["last_name"].ToString(), dr["gender"].ToString(), long.Parse(dr["contact_no"].ToString()), long.Parse(dr["age"].ToString()), dr["userid"].ToString(), dr["password_user"].ToString(), dr["userType"].ToString(), dr["emailId"].ToString(), dr["description"].ToString()));
                }
                return(trainerSearch);
            }
        }
Example #15
0
        public bool Delete(Guid Id, Guid?userId)
        {
            try
            {
                ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                var contentObj = new ContentsBO().Get(ConnectionHandler, Id);
                if (new ContentsBO().Delete(ConnectionHandler, Id) == false)
                {
                    throw new Exception();
                }
                new SyncAdapterBO().DeprecateOldVersion(ConnectionHandler, contentObj.CongressId);
                new SyncAdapterBO().Insert(ConnectionHandler, createSyncAdapter(contentObj, Enums.QueryTypes.Delete, userId));

                ConnectionHandler.CommitTransaction();

                return(true);
            }
            catch (Exception exp)
            {
                ConnectionHandler.RollBack();
            }

            return(false);
        }
        /// <summary>
        ///     c'tor
        /// </summary>
        public AzureServiceBusOutboundTransport(
            [NotNull] IAzureServiceBusEndpointAddress address,
            [NotNull] ConnectionHandler <AzureServiceBusConnection> connectionHandler,
            [NotNull] SenderSettings settings)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (connectionHandler == null)
            {
                throw new ArgumentNullException("connectionHandler");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _connectionHandler = connectionHandler;
            _settings          = settings;
            _address           = address;

            _logger.DebugFormat("created outbound transport for address '{0}'", address);
        }
        public async Task ShouldReturnWithoutListening_WhenNotConnected(
            [Frozen] Mock <IConnectionInitializer> initializer,
            [Frozen] Mock <IConnectedClientStore> store,
            ConnectedClient client,
            ConnectionHandler sut)
        {
            var connection = new TestConnection();

            initializer.Setup(x => x.ConnectAsync(connection, Cts.Token))
            .ReturnsAsync(client);

            var result = sut.HandleAsync(connection, Cts.Token);

            await Wait();

            store.Setup(x => x.Find(client.ClientId))
            .Returns <ConnectedClient?>(null);

            connection.Received = Create <TestMessage>();

            await result; // Completes without errors.

            Assert.True(result.IsCompletedSuccessfully);
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            status               = "";
            connection           = new ConnectionHandler(new Random(), this);
            menuSelected         = Menus.MainMenu;
            previousMenuSelected = menuSelected;
            rand           = new Random();
            IsMouseVisible = true;

            kb    = Keyboard.GetState();
            oldKb = Keyboard.GetState();

            mouse    = Mouse.GetState();
            oldMouse = Mouse.GetState();

            wholeScreenRect = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            menuChangeOnFrame = false;

            flagSymbolTextures = new Texture2D[6];

            base.Initialize();
        }
Example #19
0
        private static ServiceProvider StartNew <TConnection>(
            TConnection connection,
            out ConnectionHandler connectionHandler,
            out RuntimeClient runtimeClient) where TConnection : IDuplexPipe
        {
            var chan     = Channel.CreateUnbounded <Message>();
            var services = new ServiceCollection()
                           .AddHagar(hagar =>
            {
                _ = hagar.AddAssembly(typeof(Program).Assembly);
                _ = hagar.AddISerializableSupport();
            })
                           .AddSingleton <IActivator <Message>, PooledMessageActivator>()
                           .AddSingleton <Catalog>()
                           .AddSingleton <ProxyFactory>()
                           .AddSingleton(sp => ActivatorUtilities.CreateInstance <ConnectionHandler>(sp, connection, chan.Writer))
                           .AddSingleton(sp => ActivatorUtilities.CreateInstance <RuntimeClient>(sp, chan.Reader))
                           .AddSingleton <IRuntimeClient>(sp => sp.GetRequiredService <RuntimeClient>())
                           .BuildServiceProvider();

            connectionHandler = services.GetRequiredService <ConnectionHandler>();
            runtimeClient     = services.GetRequiredService <RuntimeClient>();
            return(services);
        }
Example #20
0
        /// <summary>First half builds the ring, second half tests the connection handler...</summary>
        public void RingTest()
        {
            Parameters p = new Parameters("Test", "Test");

            string[] args = "-b=.2 -c --secure_senders -s=50".Split(' ');
            Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);
            Simulator sim = new Simulator(p);

            _sim = sim;
            Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring");

            SimpleTimer.RunSteps(fifteen_mins, false);
            var         nm0 = sim.TakenIDs.Values[0];
            int         idx = 1;
            NodeMapping nm1 = null;

            do
            {
                nm1 = sim.TakenIDs.Values[idx++];
            } while(Simulator.AreConnected(nm0.Node, nm1.Node) && idx < sim.TakenIDs.Count);

            Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check");
            var ptype = new PType("chtest");
            var ch0   = new ConnectionHandler(ptype, (StructuredNode)nm0.Node);
            var ch1   = new ConnectionHandler(ptype, (StructuredNode)nm1.Node);

            ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1);

            SimpleTimer.RunSteps(fifteen_mins * 2, false);

            Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check0");
            ptype = new PType("chtest1");
            ch0   = new SecureConnectionHandler(ptype, (StructuredNode)nm0.Node, nm0.Sso);
            ch1   = new SecureConnectionHandler(ptype, (StructuredNode)nm1.Node, nm1.Sso);
            ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1);
        }
        protected void MserviceDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            SqlConnection _sqlconnection     = ConnectionHandler.GetConnection();
            TextBox       servicename        = MserviceDetails.Rows[e.RowIndex].FindControl("lblmedicareservice") as TextBox;
            TextBox       servicedescription = MserviceDetails.Rows[e.RowIndex].FindControl("lblservicedescription") as TextBox;
            int           amount             = Convert.ToInt16(MserviceDetails.DataKeys[e.RowIndex].Values["lblamount"].ToString());

            _sqlconnection.Open();
            SqlCommand _sqlCommand = new SqlCommand();

            _sqlCommand.CommandType = CommandType.Text;
            _sqlCommand.Connection  = _sqlconnection;
            _sqlCommand.CommandText = "update  Medicare_services set Service_Description=@servicedescription,Amount=@amount where Medicare_service=@medicareservice";
            _sqlCommand.Parameters.AddWithValue("@MedicareService", servicename.Text);
            _sqlCommand.Parameters.AddWithValue("@ServiceDescription", servicedescription.Text);
            _sqlCommand.Parameters.AddWithValue("@Amount", amount);
            int i = _sqlCommand.ExecuteNonQuery();

            _sqlconnection.Close();
            MserviceDetails.EditIndex = -1;
            LoadData();
            MserviceDetails.EditIndex = -1;
            LoadData();
        }
Example #22
0
        public TrainerDetails getTrainerDetails(long trainerid)
        {
            TrainerDetails tDetails = null;

            using (SqlConnection connect = ConnectionHandler.getConnection())
            {
                List <TrainerDetails> trainerDetailsList = new List <TrainerDetails>();

                connect.Open();
                SqlCommand cmd = new SqlCommand("select  * from trainer ta join trainerAvailability t on ta.trainerId=t.trainer_Id where trainer_Id=@trainerId ", connect);
                cmd.Parameters.AddWithValue("@trainerId", trainerid);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet        ds = new DataSet();
                da.Fill(ds);
                connect.Close();
                DataTable dt = ds.Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    tDetails = new TrainerDetails((long.Parse(dr["trainerId"].ToString())), dr["first_name"].ToString(), dr["last_name"].ToString(), dr["gender"].ToString(), long.Parse(dr["contact_no"].ToString()), long.Parse(dr["age"].ToString()), dr["userid"].ToString(), dr["emailId"].ToString(), dr["description"].ToString(), dr["availability_status"].ToString(), DateTime.Parse(dr["startDate"].ToString()), DateTime.Parse(dr["enddate"].ToString()));
                }
                return(tDetails);
            }
        }
        private void getOrders()
        {
            /*String URL = "https://food-order-bbcce.firebaseio.com/Orders.json";
             * JObject data = JObject.Parse(ConnectionHandler.getRequest(URL));
             * //JArray dataarr = (JArray)data;
             * //String status = data.SelectToken("status");
             * JProperty parent = (JProperty)data.Parent;
             * //String name = parent.Name;
             * MessageBox.Show(data.Root.ToString());
             * //MessageBox.Show(data.Values<string>.ToString());
             * samplePendingOrder[0] = new PendingOrderLayout(data.Children().Values().ToString() , data["-M9Te98tJAds8ga9RT0h"]["status"].ToString());
             * pendingOrdersPanel.Controls.Add(samplePendingOrder[0]);*/

            String ordersString = ConnectionHandler.SocketClient();

            String[] ordersList = ordersString.Split('/');

            int pendingOrderNumber = 0;

            String[] order;
            for (int i = 0; i < ordersList.Length; i++)
            {
                order = ordersList[i].Split('_');

                String items = "";

                for (int k = 1; k < order.Length; k++)
                {
                    items += order[k].ToString();
                }
                samplePendingOrder[pendingOrderNumber] = new PendingOrderLayout(order[0].ToString(), items);
                pendingOrdersPanel.Controls.Add(samplePendingOrder[pendingOrderNumber]);

                pendingOrderNumber++;
            }
        }
Example #24
0
 public GetTime(ConnectionHandler connection) : base(connection)
 {
 }
 public GetDriveSpace(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #26
0
 public IsRecording(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #27
0
 public override async void Handle(ConnectionHandler context)
 {
     await context.Connect();
 }
 public SetRecordingTimesWatched(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #29
0
    //TODO: complete this test daemon/server example, and a client
    //TODO: maybe generalise it and integrate it into the core
    public static void Main(string[] args)
    {
        bool isServer;

        if (args.Length == 1 && args[0] == "server")
        {
            isServer = true;
        }
        else if (args.Length == 1 && args[0] == "client")
        {
            isServer = false;
        }
        else
        {
            Console.Error.WriteLine("Usage: test-server [server|client]");
            return;
        }

        //string addr = "unix:abstract=/tmp/dbus-ABCDEFGHIJ";
        string addr = "unix:path=/tmp/dbus-ABCDEFGHIJ";

        Connection conn;

        ObjectPath myOpath   = new ObjectPath("/org/ndesk/test");
        string     myNameReq = "org.ndesk.test";

        if (!isServer)
        {
            conn = new Connection(Transport.Create(AddressEntry.Parse(addr)));
            DemoObject demo = conn.GetObject <DemoObject> (myNameReq, myOpath);
            demo.GiveNoReply();
            //float ret = demo.Hello ("hi from test client", 21);
            float ret = 200;
            while (ret > 5)
            {
                ret = demo.Hello("hi from test client", (int)ret);
                Console.WriteLine("Returned float: " + ret);
                System.Threading.Thread.Sleep(1000);
            }
        }
        else
        {
            string path;
            bool   abstr;

            AddressEntry entry = AddressEntry.Parse(addr);
            path = entry.Properties["path"];

            UnixSocket server = new UnixSocket();


            byte[] p = Encoding.Default.GetBytes(path);

            byte[] sa = new byte[2 + p.Length + 1];

            //we use BitConverter to stay endian-safe
            byte[] afData = BitConverter.GetBytes(UnixSocket.AF_UNIX);
            sa[0] = afData[0];
            sa[1] = afData[1];

            for (int i = 0; i != p.Length; i++)
            {
                sa[2 + i] = p[i];
            }
            sa[2 + p.Length] = 0;             //null suffix for domain socket addresses, see unix(7)


            server.Bind(sa);
            //server.Listen (1);
            server.Listen(5);

            while (true)
            {
                Console.WriteLine("Waiting for client on " + addr);
                UnixSocket client = server.Accept();
                Console.WriteLine("Client accepted");
                //client.Blocking = true;

                //PeerCred pc = new PeerCred (client);
                //Console.WriteLine ("PeerCred: pid={0}, uid={1}, gid={2}", pc.ProcessID, pc.UserID, pc.GroupID);

                UnixNativeTransport transport = new UnixNativeTransport();
                transport.Stream = new UnixStream(client.Handle);
                conn             = new Connection(transport);

                //ConnectionHandler.Handle (conn);

                //in reality a thread per connection is of course too expensive
                ConnectionHandler hnd = new ConnectionHandler(conn);
                new Thread(new ThreadStart(hnd.Handle)).Start();

                Console.WriteLine();
            }
        }
    }
Example #30
0
 protected sealed override Task MainLoop(TestContext ctx, CancellationToken cancellationToken)
 {
     return(ConnectionHandler.MainLoop(ctx, cancellationToken));
 }
Example #31
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="port"></param>
 /// <param name="handler"></param>
 public NetworkListener(int port, ConnectionHandler handler)
 {
     this.port = port;
     ch = handler;
     threads = new List<Thread>();
 }
	//TODO: complete this test daemon/server example, and a client
	//TODO: maybe generalise it and integrate it into the core
	public static void Main (string[] args)
	{
		bool isServer;

		if (args.Length == 1 && args[0] == "server")
			isServer = true;
		else if (args.Length == 1 && args[0] == "client")
			isServer = false;
		else {
			Console.Error.WriteLine ("Usage: test-server [server|client]");
			return;
		}

		//string addr = "unix:abstract=/tmp/dbus-ABCDEFGHIJ";
		string addr = "unix:path=/tmp/dbus-ABCDEFGHIJ";

		Connection conn;

		ObjectPath myOpath = new ObjectPath ("/org/ndesk/test");
		string myNameReq = "org.ndesk.test";

		if (!isServer) {
			conn = new Connection (Transport.Create (AddressEntry.Parse (addr)));
			DemoObject demo = conn.GetObject<DemoObject> (myNameReq, myOpath);
			demo.GiveNoReply ();
			//float ret = demo.Hello ("hi from test client", 21);
			float ret = 200;
			while (ret > 5) {
				ret = demo.Hello ("hi from test client", (int)ret);
				Console.WriteLine ("Returned float: " + ret);
				System.Threading.Thread.Sleep (1000);
			}
		} else {
			string path;
			bool abstr;

			AddressEntry entry = AddressEntry.Parse (addr);
			path = entry.Properties["path"];

			UnixSocket server = new UnixSocket ();


			byte[] p = Encoding.Default.GetBytes (path);

			byte[] sa = new byte[2 + p.Length + 1];

			//we use BitConverter to stay endian-safe
			byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX);
			sa[0] = afData[0];
			sa[1] = afData[1];

			for (int i = 0 ; i != p.Length ; i++)
				sa[2 + i] = p[i];
			sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7)


			server.Bind (sa);
			//server.Listen (1);
			server.Listen (5);

			while (true) {
				Console.WriteLine ("Waiting for client on " + addr);
				UnixSocket client = server.Accept ();
				Console.WriteLine ("Client accepted");
				//client.Blocking = true;

				//PeerCred pc = new PeerCred (client);
				//Console.WriteLine ("PeerCred: pid={0}, uid={1}, gid={2}", pc.ProcessID, pc.UserID, pc.GroupID);

				UnixNativeTransport transport = new UnixNativeTransport ();
				transport.Stream = new UnixStream (client.Handle);
				conn = new Connection (transport);

				//ConnectionHandler.Handle (conn);

				//in reality a thread per connection is of course too expensive
				ConnectionHandler hnd = new ConnectionHandler (conn);
				new Thread (new ThreadStart (hnd.Handle)).Start ();

				Console.WriteLine ();
			}
		}
	}
 public GetCardSettings(ConnectionHandler connection)
     : base(connection)
 {
 }
 public TimeshiftChannel(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #35
0
    private GameObject GenerateMesh(int gx, int gy)
    {
        //int b = BOXSIZE - ( gx != 0 ? 0 : 0 );
        //int h = BOXSIZE - ( gy != 0 ? 0 : 0 );

        int numfloats = (1 + (BOXSIZE-1) * BOXES);

        GameObject groundMesh;

        float[][] meshbox = new float[BOXSIZE][];
        for (int i = 0; i < BOXSIZE; i++) meshbox[i] = new float[BOXSIZE];

        float[][] meshbox2 = new float[numfloats][];
        for (int i = 0; i < meshbox2.Length; i++) meshbox2[i] = new float[numfloats];

        if (otherway) {

            int mid = (BOXES-1)/2;

            for (int i = 0; i < BOXES; i++) {
                for (int j = 0; j < BOXES; j++) {

                    ConnectionHandler c1 = new ConnectionHandler();
                    c1.get_block_datao(j - mid, i - mid, meshbox2, i * (BOXSIZE-1), j * (BOXSIZE-1));

                }
            }

            groundMesh = WeaveMaster(gx, gy, meshbox2);

        }
        else {

            ConnectionHandler c1 = new ConnectionHandler();
            c1.get_block_data(gx, gy, meshbox);

            groundMesh = WeaveMaster(gx, gy, meshbox);

        }

        groundMesh.AddComponent<GroundMesh>();
        groundMesh.GetComponent<GroundMesh>().gX = gx;
        groundMesh.GetComponent<GroundMesh>().gY = gy;
        localCoordinates.Add(new Vector2(gx,gy),groundMesh);
        PlaceGroundMeshGXGY(groundMesh,gx,gy);

        return groundMesh;
    }
Example #36
0
 public AuthService(UserProperties user, ConnectionHandler conn)
 {
     _user = user;
     _conn = conn;
 }
Example #37
0
    void GenerateMesh(int gx, int gy)
    {
        float[][] meshbox = new float[BOXSIZE][];
        for (int i = 0; i < BOXSIZE; i++)
            meshbox[i] = new float[BOXSIZE];

        ConnectionHandler c1 = new ConnectionHandler();
        c1.get_block_data(gx, gy, meshbox);

        GameObject groundMesh = WeaveMaster(gx, gy, meshbox);
        groundMesh.AddComponent<GroundMesh>();
        groundMesh.GetComponent<GroundMesh>().gX = gx;
        groundMesh.GetComponent<GroundMesh>().gY = gy;
        localCoordinates.Add(new Vector2(gx,gy),groundMesh);

        PlaceGroundMeshGXGY(groundMesh,gx,gy);
    }
Example #38
0
 public GetVersion(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #39
0
 public void Handle()
 {
     ConnectionHandler.Handle(conn);
 }
 public ListSchedules(ConnectionHandler connection)
     : base(connection)
 {
 }
    private GameObject GenerateMesh(int gx, int gy)
    {
        float[][] meshbox = new float[BOXSIZE][];
        for (int i = 0; i < BOXSIZE; i++)
            meshbox[i] = new float[BOXSIZE];

        ConnectionHandler c1 = new ConnectionHandler();
        c1.get_block_data(gx, gy, meshbox);

        GameObject groundMesh = WeaveMaster(gx, gy, meshbox);
        groundMesh.AddComponent<GroundMesh>();
        groundMesh.GetComponent<GroundMesh>().gX = gx;
        groundMesh.GetComponent<GroundMesh>().gY = gy;
        PlaceGroundMeshGXGY(groundMesh,gx,gy);

        return groundMesh;
    }
 public ListTVChannels(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #43
0
 public ListGroups(ConnectionHandler connection)
     : base(connection)
 {
 }
 public DefaultConnectionPolicy(ConnectionHandler connectionHandler)
 {
     _connectionHandler = connectionHandler;
     _reconnectDelay = 10.Seconds();
 }
Example #45
0
 public void getMesh(float[][] mesh)
 {
     ConnectionHandler c1 = new ConnectionHandler();
     //new Thread(new ThreadStart(c1.get_block_data)).Start();
     //c1.get_block_data(mesh);
 }
        public AVRenderer(int MaxConnections, ProtocolInfoString[] Info, ConnectionHandler h)
        {
            ConnectionMax = MaxConnections;
            OnNewConnection += h;

            InfoStrings = Info;
            device = UPnPDevice.CreateEmbeddedDevice(1,Guid.NewGuid().ToString());
            device.FriendlyName = "AVRenderer Device (" + Dns.GetHostName() +")";

            AVT = new DvAVTransport();
            AVT.GetUPnPService().Major = 1;
            AVT.GetUPnPService().Minor = 0;

            Manager = new DvConnectionManager();
            Manager.GetUPnPService().Major = 1;
            Manager.GetUPnPService().Minor = 0;

            Control = new DvRenderingControl();
            Control.GetUPnPService().Major = 1;
            Control.GetUPnPService().Minor = 0;

            Manager.External_PrepareForConnection = new DvConnectionManager.Delegate_PrepareForConnection(PrepareForConnectionSink);
            Manager.External_ConnectionComplete = new DvConnectionManager.Delegate_ConnectionComplete(ConnectionCompleteSink);
            Manager.External_GetCurrentConnectionIDs = new DvConnectionManager.Delegate_GetCurrentConnectionIDs(GetCurrentConnectionIDsSink);
            Manager.External_GetProtocolInfo = new DvConnectionManager.Delegate_GetProtocolInfo(GetProtocolInfoSink);
            Manager.External_GetCurrentConnectionInfo = new DvConnectionManager.Delegate_GetCurrentConnectionInfo(GetCurrentConnectionInfoSink);

            Manager.Evented_CurrentConnectionIDs = "";
            //Manager.Evented_PhysicalConnections = "";

            string Sink = "";
            foreach(ProtocolInfoString s in InfoStrings)
            {
                if(Sink=="")
                {
                    Sink = s.ToString();
                }
                else
                {
                    Sink = Sink + "," + s.ToString();
                }
            }

            Manager.Evented_SinkProtocolInfo = Sink;
            Manager.Evented_SourceProtocolInfo = "";

            AVT.Accumulator_LastChange = new InstanceID_LastChangeAccumulator("AVT");
            AVT.ModerationDuration_LastChange = 0.5;
            AVT.Evented_LastChange = "&lt;Event xmlns = &quot;urn:schemas-upnp-org:metadata-1-0/AVT/&quot;/&gt;";

            AVT.External_GetMediaInfo = new DvAVTransport.Delegate_GetMediaInfo(GetMediaInfoSink);
            AVT.External_GetPositionInfo = new DvAVTransport.Delegate_GetPositionInfo(GetPositionInfoSink);
            AVT.External_GetTransportInfo = new DvAVTransport.Delegate_GetTransportInfo(GetTransportInfoSink);
            AVT.External_GetTransportSettings = new DvAVTransport.Delegate_GetTransportSettings(GetTransportSettingsSink);
            AVT.External_GetDeviceCapabilities = new DvAVTransport.Delegate_GetDeviceCapabilities(GetDeviceCapabilitiesSink);
            AVT.External_GetCurrentTransportActions = new DvAVTransport.Delegate_GetCurrentTransportActions(GetCurrentTransportActionsSink);

            AVT.External_Play = new DvAVTransport.Delegate_Play(PlaySink);
            AVT.External_Stop = new DvAVTransport.Delegate_Stop(StopSink);
            AVT.External_Pause = new DvAVTransport.Delegate_Pause(PauseSink);
            AVT.External_Record = new DvAVTransport.Delegate_Record(RecordSink);
            AVT.External_Previous = new DvAVTransport.Delegate_Previous(PreviousSink);
            AVT.External_Next = new DvAVTransport.Delegate_Next(NextSink);
            AVT.External_Seek = new DvAVTransport.Delegate_Seek(SeekSink);
            AVT.External_SetAVTransportURI = new DvAVTransport.Delegate_SetAVTransportURI(SetAVTransportURISink);
            AVT.External_SetNextAVTransportURI = new DvAVTransport.Delegate_SetNextAVTransportURI(SetNextAVTransportURISink);
            AVT.External_SetPlayMode = new DvAVTransport.Delegate_SetPlayMode(SetPlayModeSink);
            AVT.External_SetRecordQualityMode = new DvAVTransport.Delegate_SetRecordQualityMode(SetRecordQualityModeSink);
            AVT.External_Record = new DvAVTransport.Delegate_Record(RecordSink);

            Control.Evented_LastChange = "&lt;Event xmlns = &quot;urn:schemas-upnp-org:metadata-1-0/RCS/&quot;/&gt;";

            Control.Accumulator_LastChange = new InstanceID_LastChangeAccumulator("RCS");
            Control.ModerationDuration_LastChange = 1;

            Control.External_GetMute = new DvRenderingControl.Delegate_GetMute(GetMuteSink);
            Control.External_SetMute = new DvRenderingControl.Delegate_SetMute(SetMuteSink);
            Control.External_GetVolume = new DvRenderingControl.Delegate_GetVolume(GetVolumeSink);
            Control.External_SetVolume = new DvRenderingControl.Delegate_SetVolume(SetVolumeSink);
            Control.External_GetBlueVideoBlackLevel  = new DvRenderingControl.Delegate_GetBlueVideoBlackLevel(GetBlueVideoBlackSink);
            Control.External_GetBlueVideoGain = new DvRenderingControl.Delegate_GetBlueVideoGain(GetBlueVideoGainSink);
            Control.External_SetBlueVideoBlackLevel = new DvRenderingControl.Delegate_SetBlueVideoBlackLevel(SetBlueVideoBlackSink);
            Control.External_SetBlueVideoGain = new DvRenderingControl.Delegate_SetBlueVideoGain(SetBlueVideoGainSink);
            Control.External_GetGreenVideoBlackLevel  = new DvRenderingControl.Delegate_GetGreenVideoBlackLevel(GetGreenVideoBlackSink);
            Control.External_GetGreenVideoGain = new DvRenderingControl.Delegate_GetGreenVideoGain(GetGreenVideoGainSink);
            Control.External_SetGreenVideoBlackLevel = new DvRenderingControl.Delegate_SetGreenVideoBlackLevel(SetGreenVideoBlackSink);
            Control.External_SetGreenVideoGain = new DvRenderingControl.Delegate_SetGreenVideoGain(SetGreenVideoGainSink);
            Control.External_GetRedVideoBlackLevel  = new DvRenderingControl.Delegate_GetRedVideoBlackLevel(GetRedVideoBlackSink);
            Control.External_GetRedVideoGain = new DvRenderingControl.Delegate_GetRedVideoGain(GetRedVideoGainSink);
            Control.External_SetRedVideoBlackLevel = new DvRenderingControl.Delegate_SetRedVideoBlackLevel(SetRedVideoBlackSink);
            Control.External_SetRedVideoGain = new DvRenderingControl.Delegate_SetRedVideoGain(SetRedVideoGainSink);
            Control.External_GetBrightness = new DvRenderingControl.Delegate_GetBrightness(GetBrightnessSink);
            Control.External_SetBrightness = new DvRenderingControl.Delegate_SetBrightness(SetBrightnessSink);
            Control.External_GetContrast = new DvRenderingControl.Delegate_GetContrast(GetContrastSink);
            Control.External_SetContrast = new DvRenderingControl.Delegate_SetContrast(SetContrastSink);
            Control.External_GetSharpness = new DvRenderingControl.Delegate_GetSharpness(GetSharpnessSink);
            Control.External_SetSharpness = new DvRenderingControl.Delegate_SetSharpness(SetSharpnessSink);

            Control.External_ListPresets = new DvRenderingControl.Delegate_ListPresets(ListPresetsSink);
            Control.External_SelectPreset = new DvRenderingControl.Delegate_SelectPreset(SelectPresetSink);

            device.Manufacturer = "OpenSource";
            device.ManufacturerURL = "";
            device.PresentationURL = "/";
            device.HasPresentation = false;
            device.ModelName = "Renderer";
            device.ModelDescription = "AV Media Renderer Device";
            device.ModelURL = new Uri("http://www.sourceforge.org");
            device.StandardDeviceType = "MediaRenderer";

            device.AddService(Manager);
            device.AddService(Control);
            device.AddService(AVT);

            if(ConnectionMax == 0)
            {
                Manager.Evented_CurrentConnectionIDs = "0";
                CurrentConnections = 1;
                AVConnection c = new AVConnection(this, "", "/", -1, DvConnectionManager.Enum_A_ARG_TYPE_Direction.INPUT, 0, 0, 0);
                c.Parent = this;
                c._WhoCreatedMe = new IPEndPoint(IPAddress.Parse("127.0.0.1"),0);
                ID_Table[(UInt32)0] = c;
                if(h!=null) h(this,c);
            }
        }
		public InboundRabbitMqTransport(IRabbitMqEndpointAddress address,
		                                ConnectionHandler<RabbitMqConnection> connectionHandler)
		{
			_address = address;
			_connectionHandler = connectionHandler;
		}
Example #48
0
 public DeleteRecordedTV(ConnectionHandler connection)
     : base(connection)
 {
 }
 public async Task UpdateReadingAsync(Vector3 reading)
 {
     LatestReading = reading;
     await ConnectionHandler.SendAsync(EncodedLatestReading);
 }
Example #50
0
 protected OutboundMsmqTransport(IMsmqEndpointAddress address,
                                 ConnectionHandler <MessageQueueConnection> connectionHandler)
 {
     _address           = address;
     _connectionHandler = connectionHandler;
 }
 public SetRecordingStopTime(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #52
0
 public DeleteSchedule(ConnectionHandler connection)
     : base(connection)
 {
 }
		protected InboundMsmqTransport(IMsmqEndpointAddress address, ConnectionHandler<MessageQueueConnection> connectionHandler)
		{
			_address = address;
			_connectionHandler = connectionHandler;
		}
Example #54
0
 public UpdateRecording(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #55
0
 public ListRadioChannels(ConnectionHandler connection) : base(connection)
 {
 }
Example #56
0
		public ReconnectPolicy(ConnectionHandler connectionHandler, ConnectionPolicyChain policyChain, TimeSpan reconnectDelay)
		{
			_connectionHandler = connectionHandler;
			_policyChain = policyChain;
			_reconnectDelay = reconnectDelay;
		}
 public GetBackendName(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #58
0
 public Help(ConnectionHandler connection)
     : base(connection)
 {
 }
Example #59
0
 public RuntimeClient(ConnectionHandler connection, Catalog catalog, ChannelReader <Message> incomingMessages)
 {
     this.connection       = connection;
     this.catalog          = catalog;
     this.incomingMessages = incomingMessages;
 }
Example #60
0
 public GetEPG(ConnectionHandler connection)
     : base(connection)
 {
 }