Package org.red5.server.api

Examples of org.red5.server.api.IClient


   * Calls the checkBandwidth method on the current client.
   * @param o Object passed from Flash, not used at the moment
   */
  public void checkBandwidth(Object o) {
    //Incoming object should be null
    IClient client = Red5.getConnectionLocal().getClient();
    if (client != null) {
      client.checkBandwidth();
    }
  }
View Full Code Here


   * Calls the checkBandwidthUp method on the current client.
   * @param params Object passed from Flash
   */
  public Map<String, Object> checkBandwidthUp(Object[] params) {
    //Incoming object should be null
    IClient client = Red5.getConnectionLocal().getClient();
    if (client != null) {
      return client.checkBandwidthUp(params);
    }
    return null;
  }
View Full Code Here

  private void setClientId(AbstractMessage msg) {
    String clientId = msg.getClientId();
    if (clientId == null || "null".equals(clientId)) {
      log.trace("Dump: {}", msg);
      //use the connection client id before creating a new one
      IClient client = Red5.getConnectionLocal().getClient();
      if (client != null) {
        //should we format it?
        clientId = client.getId();
        msg.setClientId(RandomGUID.getPrettyFormatted(clientId));
      } else {
        msg.setClientId(UUID.randomUUID().toString());
      }
    }
View Full Code Here

     
        return true;           
   
  public String whoami() {
      IConnection conn = Red5.getConnectionLocal();
      IClient client = conn.getClient();
      IScope scope = conn.getScope();
      return client.getId();
      // ...
  }
View Full Code Here

    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

    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

    @SuppressWarnings("deprecation")
    public void runTest() throws Throwable {
      Red5.setConnectionLocal(conn);

      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) {
              serviceCapCon = (IServiceCapableConnection) rcon;
View Full Code Here

   * @throws ClientRejectedException if client rejected
   */
  public IClient newClient(Object[] params) throws ClientNotFoundException, ClientRejectedException {
    // derive client id from the connection params or use next
    String id = nextId();
    IClient client = new Client(id, this);
    addClient(id, client);
    return client;
  }
View Full Code Here

      if (!conn.isConnected()) {
        log.debug("Connection is not connected");
        // timeout while connecting client
        return false;
      }
      final IClient client = conn.getClient();
      // we would not get this far if there is no handler
      if (hasHandler() && !getHandler().join(client, this)) {
        return false;
      }
      // checking the connection again? why?
View Full Code Here

   * @param conn Connection object
   */
  public void disconnect(IConnection conn) {
    log.debug("Disconnect: {}", conn);
    // call disconnect handlers in reverse order of connection. ie. roomDisconnect is called before appDisconnect.
    final IClient client = conn.getClient();
    if (client == null) {
      // early bail out
      removeEventListener(conn);
      connectionStats.decrement();
      if (hasParent()) {
View Full Code Here

TOP

Related Classes of org.red5.server.api.IClient

Copyright © 2018 www.massapicom. 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.