Java Code Examples for java.nio.channels.SocketChannel#equals()
The following examples show how to use
java.nio.channels.SocketChannel#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
public void replace(String itemName, Direction direction, InetSocketAddress remoteAddress, SocketChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (useAddressMask && (aChannel.host.equals("*") || aChannel.port.equals("*")) && direction.equals(aChannel.direction) && itemName.equals(aChannel.item) && !channel.equals(aChannel.channel)) { if (aChannel.host.equals("*") && aChannel.port.equals(Integer.toString(remoteAddress.getPort()))) { aChannel.channel = channel; } else if (aChannel.port.equals("*") && aChannel.host.equals(remoteAddress.getHostString())) { aChannel.channel = channel; } else if (aChannel.port.equals("*") && aChannel.host.equals("*")) { aChannel.channel = channel; } } else if (itemName.equals(aChannel.item) && remoteAddress.equals(aChannel.remote) && direction.equals(aChannel.direction) && !channel.equals(aChannel.channel)) { aChannel.channel = channel; } } } }
Example 2
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
public ArrayList<Channel> getAll(String itemName, Direction direction, SocketChannel theSocketChannel) { synchronized (this) { ArrayList<Channel> selectedChannels = new ArrayList<Channel>(); Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (itemName.equals(aChannel.item) && theSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { selectedChannels.add(aChannel); } } return selectedChannels; } }
Example 3
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
public void replace(Direction direction, InetSocketAddress remoteAddress, SocketChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (useAddressMask && (aChannel.host.equals("*") || aChannel.port.equals("*")) && remoteAddress.equals(aChannel.remote) && direction.equals(aChannel.direction) && !channel.equals(aChannel.channel)) { if (aChannel.host.equals("*") && aChannel.port.equals(Integer.toString(remoteAddress.getPort()))) { aChannel.channel = channel; } else if (aChannel.port.equals("*") && aChannel.host.equals(remoteAddress.getHostString())) { aChannel.channel = channel; } else if (aChannel.port.equals("*") && aChannel.host.equals("*")) { aChannel.channel = channel; } } else if (remoteAddress.equals(aChannel.remote) && direction.equals(aChannel.direction) && !channel.equals(aChannel.channel)) { aChannel.channel = channel; } } } }
Example 4
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
public void replace(InetSocketAddress remoteAddress, SocketChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (useAddressMask && (aChannel.host.equals("*") || aChannel.port.equals("*")) && !channel.equals(aChannel.channel)) { if (aChannel.host.equals("*") && aChannel.port.equals(Integer.toString(remoteAddress.getPort()))) { aChannel.channel = channel; } else if (aChannel.port.equals("*") && aChannel.host.equals(remoteAddress.getHostString())) { aChannel.channel = channel; } else if (aChannel.port.equals("*") && aChannel.host.equals("*")) { aChannel.channel = channel; } } else if (remoteAddress.equals(aChannel.remote) && !channel.equals(aChannel.channel)) { aChannel.channel = channel; } } } }
Example 5
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public ArrayList<Channel> getAll(Direction direction, SocketChannel theSocketChannel) { synchronized (this) { ArrayList<Channel> selectedChannels = new ArrayList<Channel>(); Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { selectedChannels.add(aChannel); } } return selectedChannels; } }
Example 6
Source File: AbstractDatagramChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void replace(Direction direction, SocketChannel oldSocketChannel, DatagramChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (oldSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { aChannel.channel = channel; } } } }
Example 7
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public Channel getBlocking(SocketChannel theSocketChannel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel) && aChannel.isBlocking) { return aChannel; } } return null; } }
Example 8
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public boolean isBlocking(SocketChannel theSocketChannel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel) && aChannel.isBlocking) { return true; } } return false; } }
Example 9
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void setAllReconnecting(SocketChannel theSocketChannel, boolean b) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel)) { aChannel.isReconnecting = b; } } } }
Example 10
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void setAllBlocking(SocketChannel theSocketChannel, boolean b) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel)) { aChannel.isBlocking = b; } } } }
Example 11
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public ArrayList<Channel> getAll(SocketChannel theSocketChannel) { synchronized (this) { ArrayList<Channel> selectedChannels = new ArrayList<Channel>(); Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel)) { selectedChannels.add(aChannel); } } return selectedChannels; } }
Example 12
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void replace(SocketChannel oldSocketChannel, SocketChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (oldSocketChannel.equals(aChannel.channel)) { aChannel.channel = channel; } } } }
Example 13
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void setAllBlocking(Direction direction, SocketChannel theSocketChannel, boolean b) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { aChannel.isBlocking = b; } } } }
Example 14
Source File: RRServer.java From twister2 with Apache License 2.0 | 5 votes |
/** * Send a response to a request id * @param requestID request id * @param message message * @return true if response was accepted */ public boolean sendResponse(RequestID requestID, Message message) { if (!requestChannels.containsKey(requestID)) { LOG.log(Level.SEVERE, "Trying to send a response to non-existing request"); return false; } SocketChannel channel = requestChannels.get(requestID); if (channel == null) { LOG.log(Level.SEVERE, "Channel is NULL for response"); } if (!workerChannels.containsKey(channel) && !channel.equals(clientChannel)) { LOG.log(Level.WARNING, "Failed to send response on disconnected socket"); return false; } TCPMessage tcpMessage = sendMessage(message, requestID, channel); if (tcpMessage != null) { requestChannels.remove(requestID); return true; } else { return false; } }
Example 15
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void replace(Direction direction, SocketChannel oldSocketChannel, SocketChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (oldSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { aChannel.channel = channel; } } } }
Example 16
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void setAllBlocking(String itemName, Direction direction, SocketChannel theSocketChannel, boolean b) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (itemName.equals(aChannel.item) && theSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { aChannel.isBlocking = b; } } } }
Example 17
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public void replace(String itemName, Direction direction, SocketChannel oldSocketChannel, SocketChannel channel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (itemName.equals(aChannel.item) && oldSocketChannel.equals(aChannel.channel) && direction.equals(aChannel.direction)) { aChannel.channel = channel; } } } }
Example 18
Source File: AbstractSocketChannelBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
public Channel get(SocketChannel theChannel) { synchronized (this) { Iterator<C> it = iterator(); while (it.hasNext()) { C aChannel = it.next(); if (theChannel.equals(aChannel.channel)) { return aChannel; } } return null; } }
Example 19
Source File: RRServer.java From twister2 with Apache License 2.0 | 5 votes |
@Override public void onClose(SocketChannel channel) { workerChannels.remove(channel); connectedChannels.remove(channel); connectHandler.onClose(channel); if (channel.equals(clientChannel)) { clientChannel = null; } }