jnetrobust
1.0.0
Java 6+용 빠르고 안정적이며 방해가 되지 않는 메시지 지향 가상 네트워크 프로토콜입니다.
현재 알파 상태입니다.
JNetRobust는 전송 계층과 애플리케이션 계층 사이에 있는 가상 네트워크 프로토콜입니다.
이익
주의사항
안정성이 필요하지 않으면 UDP를 사용하십시오.
안정성이 필요하고 유효성이 검증될 때까지 기다릴 수 있는 경우 TCP를 사용하세요.
안정성이 필요하지만 대기 시간 없이 검증되지 않은 데이터를 수신함으로써 이점을 얻을 수 있는 경우 JNetRobust를 사용해 보십시오.
이는 라이브러리이며 사용 방법에 제한을 두지 않습니다.
시작하기 위해 모든 조각을 하나로 묶는 참조 구현을 사용할 수 있습니다. 예가 아래에 나열되어 있습니다.
추가 정보는 위키 페이지를 참조하세요!
다음은 제공된 참조 구현을 사용하는 최소한의 완전한 예입니다.
암호
public class BidirectionalMain {
public static void main ( String [] args ) throws Exception {
String receivedMessage ;
// host addresses
InetSocketAddress ADDRESS_A = new InetSocketAddress ( InetAddress . getLocalHost (), 12345 );
InetSocketAddress ADDRESS_B = new InetSocketAddress ( InetAddress . getLocalHost (), 12346 );
// setup ProtocolHosts using the host's local address and registering all serialization dataTypes
// ProtocolHost supports multiplexing between different peers using respective topicId, remote address and dataType
ProtocolHost protocolHostA = new ProtocolHost ( "A" , ADDRESS_A , String . class );
ProtocolHandle < String > protocolHandleA = protocolHostA . register ( Byte . MIN_VALUE , ADDRESS_B );
ProtocolHost protocolHostB = new ProtocolHost ( "B" , ADDRESS_B , String . class );
ProtocolHandle < String > protocolHandleB = protocolHostB . register ( Byte . MIN_VALUE , ADDRESS_A );
// send from A
protocolHandleA . send ( Arrays . asList ( "Hi!" , "How you doing?" ));
System . out . println ();
Thread . sleep ( 100 );
// receive at B
while (( receivedMessage = protocolHandleB . receive ()) != null ) {
System . out . println ( "<B> t " + receivedMessage );
}
// send from B
protocolHandleB . send ( "Howdy! Fine, thanks." );
System . out . println ();
Thread . sleep ( 100 );
// receive at A
while (( receivedMessage = protocolHandleA . receive ()) != null ) {
System . out . println ( "<A> t " + receivedMessage );
}
}
}
콘솔 출력
[A]: Data sent -32767 Hi!
[A]: Data sent -32766 How you doing?
[B]: Data received ordered -32767 Hi!
[B]: Data received -32767 Hi!
[B]: Data received ordered -32766 How you doing?
[B]: Data received -32766 How you doing?
[B]: Newest data received -32766 How you doing?
<B> Hi!
<B> How you doing?
[B]: Data sent -32767 Howdy! Fine, thanks.
[A]: Data was received at other end -32767 Hi!
[A]: Data was received at other end -32766 How you doing?
[A]: Data received ordered -32767 Howdy! Fine, thanks.
[A]: Data received -32767 Howdy! Fine, thanks.
[A]: Newest data received -32767 Howdy! Fine, thanks.
<A> Howdy! Fine, thanks.
메이븐
<!-- JNetRobust library; mandatory -->
< dependency >
< groupId >com.github.mucaho</ groupId >
< artifactId >jnetrobust-core</ artifactId >
< version >0.0.2</ version >
</ dependency >
<!-- JNetRobust examples; optional -->
< dependency >
< groupId >com.github.mucaho</ groupId >
< artifactId >jnetrobust-samples</ artifactId >
< version >0.0.2</ version >
</ dependency >
수동 설정
릴리스 섹션에서 jar
를 다운로드하여 클래스 경로로 가져올 수 있습니다.
JNetRobusts의 IO 페이지에서 문서를 읽을 수 있습니다.
공개 이슈 및/또는 공개 풀 요청 . 제안, 버그 보고서, 코드 개선 및 추가 기능을 환영합니다!
Copyright (c) 2014 무카호.
MPL 2.0. 간단한 설명을 읽어보세요. 수정 사항이 있는 경우 풀 요청을 통해 이 원본 저장소에 기여하는 것을 권장하고 싶습니다.