Package handlers.link

Source Code of handlers.link.GetAddressHandler

package handlers.link;


import handlers.AbstractServerHandler;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;

import common.ClientServerProtocol;

import connection.ClientConnection;
import static main.ServerMain.*;


public class GetAddressHandler extends AbstractServerHandler
{
  public void execute(ClientConnection connection, ObjectInputStream is,
      ObjectOutputStream os) throws IOException, ClassNotFoundException
  {
    int clientId = is.readInt();

    ClientConnection client = getConnectionManager().getClientById(clientId);
    if (client == null)
    {
      throw new IOException();
    }

    os.write(ClientServerProtocol.PROTOCOL_LINK);
    os.write(ClientServerProtocol.Link.OP_ADDRESS);
    os.writeInt(clientId);
    os.writeObject(new InetSocketAddress(client.getAddress(), client.getPort()));
  }

}
TOP

Related Classes of handlers.link.GetAddressHandler

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.