package Communication.Messages.TCP;
import Communication.Messages.Service.*;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
public class SendingStreamThread extends QueueSendingThread
{
private final int port;
public SendingStreamThread(int port)
{
this.port = port;
}
public void send(InetAddress address, Object o)
{
this.addToSendQueue(new InetSocketAddress(address, this.port), o);
}
@Override
protected MessageSession getSession(SendObject so) throws IOException
{
MessageSession messageSession;
if ((messageSession = MessageFactory.getInstance().getSession(so.recipient)) == null)
{
messageSession = MessageFactory.getInstance().getSession(new Socket(so.recipient.getAddress(), so.recipient.getPort()));
}
return messageSession;
}
}