本文整理汇总了Java中org.apache.catalina.tribes.io.XByteBuffer.firstIndexOf方法的典型用法代码示例。如果您正苦于以下问题:Java XByteBuffer.firstIndexOf方法的具体用法?Java XByteBuffer.firstIndexOf怎么用?Java XByteBuffer.firstIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.tribes.io.XByteBuffer
的用法示例。
在下文中一共展示了XByteBuffer.firstIndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receive
import org.apache.catalina.tribes.io.XByteBuffer; //导入方法依赖的package包/类
/**
* Receive a datagram packet, locking wait
* @throws IOException
*/
public void receive() throws IOException {
boolean checkexpired = true;
try {
socket.receive(receivePacket);
if(receivePacket.getLength() > MAX_PACKET_SIZE) {
log.error("Multicast packet received was too long, dropping package:"+receivePacket.getLength());
} else {
byte[] data = new byte[receivePacket.getLength()];
System.arraycopy(receivePacket.getData(), receivePacket.getOffset(), data, 0, data.length);
if (XByteBuffer.firstIndexOf(data,0,MemberImpl.TRIBES_MBR_BEGIN)==0) {
memberDataReceived(data);
} else {
memberBroadcastsReceived(data);
}
}
} catch (SocketTimeoutException x ) {
//do nothing, this is normal, we don't want to block forever
//since the receive thread is the same thread
//that does membership expiration
}
if (checkexpired) checkExpired();
}
示例2: receive
import org.apache.catalina.tribes.io.XByteBuffer; //导入方法依赖的package包/类
/**
* Receive a datagram packet, locking wait
*
* @throws IOException
*/
public void receive() throws IOException {
boolean checkexpired = true;
try {
socket.receive(receivePacket);
if (receivePacket.getLength() > MAX_PACKET_SIZE) {
log.error("Multicast packet received was too long, dropping package:" + receivePacket.getLength());
} else {
byte[] data = new byte[receivePacket.getLength()];
System.arraycopy(receivePacket.getData(), receivePacket.getOffset(), data, 0, data.length);
if (XByteBuffer.firstIndexOf(data, 0, MemberImpl.TRIBES_MBR_BEGIN) == 0) {
memberDataReceived(data);
} else {
memberBroadcastsReceived(data);
}
}
} catch (SocketTimeoutException x) {
// do nothing, this is normal, we don't want to block forever
// since the receive thread is the same thread
// that does membership expiration
}
if (checkexpired)
checkExpired();
}