Package com.sun.sgs.app

Examples of com.sun.sgs.app.ClientSession


        Channel channel = channelService.getChannel(channelName);
        List<String> users =
      new ArrayList<String>(Arrays.asList(someUsers));
        Iterator<ClientSession> iter = channel.getSessions();
        while (iter.hasNext()) {
      ClientSession session = iter.next();
      if (!(session instanceof ClientSessionWrapper)) {
          fail("session not ClientSessionWrapper instance: " +
         session);
      }
      String name = session.getName();
      if (! users.contains(name)) {
          fail("unexpected channel member: " + name);
      } else {
          System.err.println("getSessions includes: " + name);
          users.remove(name);
View Full Code Here


  try {
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
        ClientSession session =
      (ClientSession) dataService.getBinding(user);
        channel.join(session);
        dataService.removeObject(channel);
        try {
      channel.leave(session);
View Full Code Here

  try {
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
 
        ClientSession moe =
      (ClientSession) dataService.getBinding(MOE);
        channel.join(moe);

        try {
      ClientSession larry =
          (ClientSession) dataService.getBinding(LARRY);
      channel.leave(larry);
      System.err.println("leave of non-member session returned");
     
        } catch (Exception e) {
      System.err.println(e);
      fail("test failed with exception: " + e);
        }
       
    }
       }, taskOwner);

      Thread.sleep(100);
     
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
 
        ClientSession moe =
      (ClientSession) dataService.getBinding(MOE);

        ClientSession larry =
      (ClientSession) dataService.getBinding(LARRY);
       
        Set<ClientSession> sessions = getSessions(channel);
        System.err.println(
      "sessions set (should only have moe): " + sessions);
View Full Code Here

      for (final String user : someUsers) {
   
    txnScheduler.runTask(new TestAbstractKernelRunnable() {
        public void run() {
      Channel channel = getChannel(channelName);
      ClientSession session = getSession(user);
      channel.leave(session);
        }}, taskOwner);

    Thread.sleep(100);
   
    txnScheduler.runTask(new TestAbstractKernelRunnable() {
        public void run() {
      Channel channel = getChannel(channelName);
      ClientSession session = getSession(user);
      if (getSessions(channel).contains(session)) {
          fail("Failed to remove session: " + session);
      }}}, taskOwner);
      }
     
View Full Code Here

  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    ChannelListener listener =
        new ValidatingChannelListener();
    dataService.setBinding(listenerName, listener);
    ClientSession session =
        (ClientSession) dataService.getBinding(user);
    Channel channel =
        channelService.createChannel(
      channelName, listener, Delivery.RELIABLE);
    channel.join(session);
      }
  }, taskOwner);

  // Wait for the client to join, and then send a channel message.
  client.assertJoinedChannel(channelName);
  client.sendChannelMessage(channelName, 0);

  // Validate that the session passed to the handleChannelMessage
  // method was a wrapped ClientSession.
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    ValidatingChannelListener listener = (ValidatingChannelListener)
        dataService.getBinding(listenerName);
    ClientSession session =
        (ClientSession) dataService.getBinding(user);
    listener.validateSession(session);
    System.err.println("sessions are equal");
      }
  }, taskOwner);
View Full Code Here

  for (int i = 0; i < numIterations; i++) {
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = channelService.getChannel(channelName);
        DataManager dataManager = AppContext.getDataManager();
        ClientSession session = (ClientSession)
      dataManager.getBinding(sessionKey);
        channel.join(session);
        channel.leave(session);
    }}, taskOwner);
  }
View Full Code Here

  DummyClient client = createDummyClient(name);
  try {
      assertTrue(client.connect(serverNode.getAppPort()).login());
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
        public void run() {
      ClientSession session = (ClientSession)
          dataService.getBinding(name);
      if (!(session instanceof ClientSessionWrapper)) {
          fail("session not instance of " +
         "ClientSessionWrapper");
      }
View Full Code Here

            counter = (Counter)
          dataManager.getBinding(counterName);
        } catch (NameNotBoundException e) {
            throw new MaybeRetryException("retry", true);
        }
        ClientSession session = (ClientSession)
            dataManager.getBinding(client.name);
        MessageBuffer buf = new MessageBuffer(4);
        buf.putInt(counter.getAndIncrement());
        session.send(ByteBuffer.wrap(buf.getBuffer()),
               delivery);
          }},
     
      identity);
    }
View Full Code Here

      assertTrue(client.login());
      final int numMessages = 3;
      for (int i = 0; i < numMessages; i++) {
    txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
          ClientSession session = (ClientSession)
        AppContext.getDataManager().getBinding(name);
          System.err.println("Sending messages");
          session.send(buf, delivery);
      } }, taskOwner);
      }
 
      System.err.println("waiting for client to receive messages");
      client.waitForClientToReceiveExpectedMessages(numMessages);
View Full Code Here

    new TestAbstractKernelRunnable() {
        int tryCount = 0;
        public void run() {
      Set<ClientSession> sessions =
          getAppListener().getSessions();
      ClientSession session = sessions.iterator().next();
      try {
          session.send(ByteBuffer.wrap(new byte[4096]));
      } catch (MessageRejectedException e) {
          fail("Should not run out of buffer space: " + e);
      }
      if (++tryCount < 100) {
          throw new MaybeRetryException("Retryable"true);
View Full Code Here

TOP

Related Classes of com.sun.sgs.app.ClientSession

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.