public AbstractProtocolDataUnit onConnect(int remoteAddress, int localAddress, Object[] parameters) {
ServiceAccessPoint serviceAccessPoint = getServiceAccessPoint(localAddress,
LlcpUtils.getServiceNameFromParameters(parameters));
if (serviceAccessPoint == null) {
return new DisconnectedMode(remoteAddress, localAddress, 2);
}
else {
if (serviceAccessPoint.canAcceptConnection(parameters)) {
Integer outgoingAddress = getFreeOutgoingAddress();
LlcpSocket llcpSocket = new LlcpSocket(new AddressPair(remoteAddress, outgoingAddress),
serviceAccessPoint);
openConnections.put(outgoingAddress, llcpSocket);
int aggreeOnMiux = aggreeOnMiux(parameters, llcpSocket);
List<Object> parameter = new ArrayList<Object>(getParameter());
if (aggreeOnMiux != 0)
parameter.add(new Miux(aggreeOnMiux));
return new ConnectComplete(remoteAddress, outgoingAddress, parameter.toArray());
}
else {
return new DisconnectedMode(remoteAddress, localAddress, 3);
}
}
}