Examples of IClientRegistry


Examples of org.red5.server.api.IClientRegistry

    log.debug("-----------------------------------------------------------------testBug631");

    final String message = "This is a test";

    //create our sender conn and set local
    IClientRegistry dummyReg = (IClientRegistry) applicationContext.getBean("global.clientRegistry");

    final IScope scp = (WebScope) applicationContext.getBean("web.scope"); //conn.getScope();
    final IContext ctx = (Context) applicationContext.getBean("web.context"); //scope.getContext();

    final IConnection recipient = new SvcCapableTestConnection("localhost", "/junit", "1");//host, path, session id
    IClient rClient = dummyReg.newClient(new Object[] { "recipient" });
    ((TestConnection) recipient).setClient(rClient);
    ((TestConnection) recipient).setScope((Scope) scp);
    ((DummyClient) rClient).registerConnection(recipient);

    final IConnection sender = new SvcCapableTestConnection("localhost", "/junit", "2");//host, path, session id
    IClient sClient = dummyReg.newClient(new Object[] { "sender" });
    ((TestConnection) sender).setClient(sClient);
    ((TestConnection) sender).setScope((Scope) scp);
    ((DummyClient) sClient).registerConnection(sender);

    Thread r = new Thread(new Runnable() {
      public void run() {
        Red5.setConnectionLocal(recipient);
        IConnection conn = Red5.getConnectionLocal();
        assertTrue(scp.connect(conn));
        try {
          Thread.sleep(120L);
        } catch (InterruptedException e) {
        }
        log.debug("Check s/c -\n s1: {} s2: {}\n c1: {} c2: {}", new Object[] { scp, conn.getScope(), ctx, conn.getScope().getContext() });
      }
    });
    Thread s = new Thread(new Runnable() {
      public void run() {
        Red5.setConnectionLocal(sender);
        IConnection conn = Red5.getConnectionLocal();
        assertTrue(scp.connect(conn));
        try {
          Thread.sleep(10L);
        } catch (InterruptedException e) {
        }
        Object[] sendobj = new Object[] { conn.getClient().getId(), message };
        // get the recipient
        IClientRegistry reg = ctx.getClientRegistry();
        IConnection rcon = reg.lookupClient("recipient").getConnections(scp).iterator().next();
        ((IServiceCapableConnection) rcon).invoke("privMessage", sendobj);
        try {
          Thread.sleep(100L);
        } catch (InterruptedException e) {
        }
        log.debug("Check s/c -\n s1: {} s2: {}\n c1: {} c2: {}", new Object[] { scp, conn.getScope(), ctx, conn.getScope().getContext() });
      }
    });
    r.start();
    s.start();
   
    r.join();
    s.join();
   
    IClientRegistry reg = ctx.getClientRegistry();
    log.debug("Client registry: {}", reg.getClass().getName());
    if (reg.hasClient("recipient")) {
      IClient recip = reg.lookupClient("recipient");
      Set<IConnection> rcons = recip.getConnections(scp);
      log.debug("Recipient has {} connections", rcons.size());
    } else {
      fail("Recipient not found");
    }
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

  }

  private IConnection createConnection(int id) {
    //create our sender conn and set local
    IClientRegistry dummyReg = (IClientRegistry) applicationContext.getBean("global.clientRegistry");

    IScope scp = (WebScope) applicationContext.getBean("web.scope");
    //IContext ctx = (Context) applicationContext.getBean("web.context");

    IConnection conn = new SvcCapableTestConnection("localhost", "/junit", id + "");//host, path, session id
    IClient rClient = dummyReg.newClient(new Object[] { "client-" + id });
    ((TestConnection) conn).setClient(rClient);
    ((TestConnection) conn).setScope((Scope) scp);
    ((DummyClient) rClient).registerConnection(conn);

    return conn;
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

      IClient client = conn.getClient();
      IScope scope = (WebScope) conn.getScope();
      IContext context = (Context) scope.getContext();

      IClientRegistry reg = context.getClientRegistry();

      IServiceCapableConnection serviceCapCon = null;

      //start standard process
      assertTrue(conn.connect(scope));

      //go through the client list and send at least one message to everyone
      for (String worker : workerList) {
        //dont send to ourself
        if (name.equals(worker)) {
          log.debug("Dont send to self");
          continue;
        }
        if (reg.hasClient(worker)) {
          IClient recip = reg.lookupClient(worker);
          Set<IConnection> rcons = recip.getConnections(scope);
          //log.debug("Recipient has {} connections", rcons.size());
          Object[] sendobj = new Object[] { client.getId(), "This is a message from " + name };
          for (IConnection rcon : rcons) {
            if (rcon instanceof IServiceCapableConnection) {
              serviceCapCon = (IServiceCapableConnection) rcon;
              serviceCapCon.invoke("privMessage", sendobj);
              break;
            } else {
              log.info("Connection is not service capable");
            }
          }
        } else {
          log.warn("Client not registered {}", worker);
        }
      }

      //number of connections
      int connectionCount = workerList.size();

      //now send N messages to random recipients
      for (int i = 0; i < 4000; i++) {
        String worker = workerList.get(rnd.nextInt(connectionCount));
        //dont send to ourself
        if (name.equals(worker)) {
          //log.debug("Dont send to self");
          continue;
        }
        if (reg.hasClient(worker)) {
          IClient recip = reg.lookupClient(worker);
          Set<IConnection> rcons = recip.getConnections(scope);
          //log.debug("Recipient has {} connections", rcons.size());
          Object[] sendobj = new Object[] { client.getId(), "This is a message from " + name };
          for (IConnection rcon : rcons) {
            if (rcon instanceof IServiceCapableConnection) {
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

  }

  @Test
  public void client() {
    log.debug("-----------------------------------------------------------------client");
    IClientRegistry reg = context.getClientRegistry();
    IClient client = reg.newClient(null);
    assertTrue("client should not be null", client != null);
  }
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

    TestConnection conn = new TestConnection(host, "/", null);
    // add the connection to thread local
    Red5.setConnectionLocal(conn);
    // resolve root
    IScope scope = context.resolveScope("/");
    IClientRegistry reg = context.getClientRegistry();
    IClient client = reg.newClient(null);
    assertNotNull(client);
    conn.initialize(client);
    if (conn.connect(scope)) {
      assertTrue("should have a scope", conn.getScope() != null);
      conn.close();
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

    log.debug("App: {}", testApp);

    TestConnection conn = new TestConnection(host, "/junit", null);
    Red5.setConnectionLocal(conn);

    IClientRegistry reg = context.getClientRegistry();
    IClient client = reg.newClient(null);
    assertTrue("client should not be null", client != null);
    log.debug("{}", client);
    String key = "key";
    String value = "value";
    client.setAttribute(key, value);
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

    setupScopes();
    IScope room5 = ScopeUtils.resolveScope(appScope, "/junit/room1/room4/room5");
    log.debug("Room 5 scope: {}", room5);
    // test section for issue #259
    // a little pre-setup is needed first
    IClientRegistry reg = context.getClientRegistry();
    IClient client = reg.newClient(null);
    TestConnection conn = new TestConnection(host, appPath, client.getId());
    conn.initialize(client);
    Red5.setConnectionLocal(conn);
    assertTrue(conn.connect(room5));
    // their code
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

    log.debug("Connection scope: {}", (connectionScope == null ? "is null" : "not null"));
    // when the scope is null bad things seem to happen, if a null scope is OK then
    // this block will need to be removed - Paul
    if (connectionScope != null) {
      // Get client registry for connection scope
      IClientRegistry clientRegistry = connectionScope.getContext().getClientRegistry();
      log.debug("Client registry: {}", (clientRegistry == null ? "is null" : "not null"));
      if (clientRegistry != null) {
        IClient client = conn.getClient();
        if (client == null) {
          if (!clientRegistry.hasClient(id)) {
              if (conn instanceof RTMPTConnection) {
                log.debug("Creating new client for RTMPT connection");
                // create a new client using the session id as the client's id
                client = new Client(id, (ClientRegistry) clientRegistry);
                clientRegistry.addClient(client);
                // set the client on the connection
                conn.setClient(client);         
              } else if (conn instanceof RTMPConnection) {
                log.debug("Creating new client for RTMP connection");
                // this is a new connection, create a new client to hold it
                client = clientRegistry.newClient(params);
                // set the client on the connection
                conn.setClient(client);
              }
          } else {
            client = clientRegistry.lookupClient(id);
            conn.setClient(client);             
          }
        } else {
          // set the client on the connection
          conn.setClient(client)
View Full Code Here

Examples of org.red5.server.api.IClientRegistry

        if (connectionScope == null) {
            return false;
        }

        // Get client registry for connection scope
        IClientRegistry clientRegistry = connectionScope.getContext().getClientRegistry();
    log.debug("Client registry: {}", (clientRegistry == null ? "is null" : "not null"));

        // Get client from registry by id or create a new one
        IClient client = clientRegistry.hasClient(id) ? clientRegistry.lookupClient(id) : clientRegistry.newClient(params);

    // We have a context, and a client object.. time to init the connection.
    conn.initialize(client);

    // we could checked for banned clients here
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.