Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WS4D
jCoAP
Commits
673fa682
Commit
673fa682
authored
Jun 21, 2017
by
Björn Butzin
Browse files
jCoAP now tests each multicast address separately. This avoids "all or nothing" problem.
parent
01a88d81
Changes
7
Hide whitespace changes
Inline
Side-by-side
ws4d-jcoap-applications/pom.xml
View file @
673fa682
...
...
@@ -82,7 +82,7 @@
<dependency>
<groupId>
org.ws4d.jcoap
</groupId>
<artifactId>
jcoap-core
</artifactId>
<version>
1.1.
4
</version>
<version>
1.1.
5
</version>
</dependency>
<dependency>
<groupId>
net.sf.ehcache
</groupId>
...
...
ws4d-jcoap-examples/pom.xml
View file @
673fa682
...
...
@@ -27,7 +27,7 @@
<dependency>
<groupId>
org.ws4d.jcoap
</groupId>
<artifactId>
jcoap-core
</artifactId>
<version>
1.1.
4
</version>
<version>
1.1.
5
</version>
</dependency>
</dependencies>
<url>
https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap
</url>
...
...
ws4d-jcoap-examples/src/org/ws4d/coap/example/multicastDiscovery/MulticastDiscoveryClient.java
0 → 100644
View file @
673fa682
package
org.ws4d.coap.example.multicastDiscovery
;
import
java.net.InetAddress
;
import
org.ws4d.coap.core.CoapClient
;
import
org.ws4d.coap.core.CoapConstants
;
import
org.ws4d.coap.core.connection.BasicCoapChannelManager
;
import
org.ws4d.coap.core.connection.api.CoapChannelManager
;
import
org.ws4d.coap.core.connection.api.CoapClientChannel
;
import
org.ws4d.coap.core.enumerations.CoapRequestCode
;
import
org.ws4d.coap.core.messages.api.CoapRequest
;
import
org.ws4d.coap.core.messages.api.CoapResponse
;
public
class
MulticastDiscoveryClient
implements
CoapClient
{
private
CoapChannelManager
channelManager
;
private
CoapClientChannel
clientChannel
;
public
static
void
main
(
String
[]
args
)
{
MulticastDiscoveryClient
coapClient
=
new
MulticastDiscoveryClient
();
System
.
out
.
println
(
"=== START Multicast Discovery Client ==="
);
/* *************************************************************************************************** */
/* Use multicast address */
/* *************************************************************************************************** */
coapClient
.
start
(
CoapConstants
.
COAP_ALL_NODES_IPV4_MC_ADDR
,
CoapConstants
.
COAP_DEFAULT_PORT
);
// coapClient.start(CoapConstants.COAP_ALL_NODES_IPV6_LL_MC_ADDR, CoapConstants.COAP_DEFAULT_PORT);
// coapClient.start(CoapConstants.COAP_ALL_NODES_IPV6_SL_MC_ADDR, CoapConstants.COAP_DEFAULT_PORT);
}
public
void
start
(
String
serverAddress
,
int
serverPort
)
{
this
.
channelManager
=
BasicCoapChannelManager
.
getInstance
();
this
.
clientChannel
=
null
;
try
{
this
.
clientChannel
=
this
.
channelManager
.
connect
(
this
,
InetAddress
.
getByName
(
serverAddress
),
serverPort
);
if
(
this
.
clientChannel
==
null
)
{
System
.
err
.
println
(
"Connect failed: clientChannel in null!"
);
System
.
exit
(-
1
);
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
e
.
getLocalizedMessage
());
System
.
exit
(-
1
);
}
/* *************************************************************************************************** */
/* Create GET request to /.well-known/core resource */
/* *************************************************************************************************** */
// initialize the request
CoapRequest
request
=
this
.
clientChannel
.
createRequest
(
CoapRequestCode
.
GET
,
"/.well-known/core"
,
false
);
// add a token to match outgoing multicast message and incoming unicast messages
request
.
setToken
(
"MCToken"
.
getBytes
());
// send the request
this
.
clientChannel
.
sendMessage
(
request
);
}
/* *************************************************************************************************** */
/* Implement callback methods */
/* *************************************************************************************************** */
@Override
public
void
onConnectionFailed
(
CoapClientChannel
channel
,
boolean
notReachable
,
boolean
resetByServer
)
{
System
.
err
.
println
(
"Connection Failed"
);
System
.
exit
(-
1
);
}
@Override
public
void
onResponse
(
CoapClientChannel
channel
,
CoapResponse
response
)
{
if
(
response
.
getPayload
()
!=
null
)
{
System
.
out
.
println
(
"Response: "
+
response
.
toString
()
+
" ("
+
new
String
(
response
.
getPayload
())
+
")"
);
}
else
{
System
.
out
.
println
(
"Response: "
+
response
.
toString
());
}
}
@Override
public
void
onMCResponse
(
CoapClientChannel
channel
,
CoapResponse
response
,
InetAddress
srcAddress
,
int
srcPort
)
{
if
(
response
.
getPayload
()
!=
null
)
{
System
.
out
.
println
(
"Response from "
+
srcAddress
.
toString
()
+
":"
+
srcPort
+
" - "
+
response
.
toString
()
+
" ("
+
new
String
(
response
.
getPayload
())
+
")"
);
}
else
{
System
.
out
.
println
(
"Response from "
+
srcAddress
.
toString
()
+
":"
+
srcPort
+
" - "
+
response
.
toString
());
}
}
}
ws4d-jcoap-handsOn/src/org/ws4d/coap/handsOn/multicastDiscovery/MulticastDiscoveryClient.java
View file @
673fa682
...
...
@@ -23,8 +23,8 @@ public class MulticastDiscoveryClient implements CoapClient {
/* *************************************************************************************************** */
/* Use multicast address */
/* *************************************************************************************************** */
//
coapClient.start(CoapConstants.COAP_ALL_NODES_IPV4_MC_ADDR, CoapConstants.COAP_DEFAULT_PORT);
coapClient
.
start
(
CoapConstants
.
COAP_ALL_NODES_IPV6_LL_MC_ADDR
,
CoapConstants
.
COAP_DEFAULT_PORT
);
coapClient
.
start
(
CoapConstants
.
COAP_ALL_NODES_IPV4_MC_ADDR
,
CoapConstants
.
COAP_DEFAULT_PORT
);
//
coapClient.start(CoapConstants.COAP_ALL_NODES_IPV6_LL_MC_ADDR, CoapConstants.COAP_DEFAULT_PORT);
// coapClient.start(CoapConstants.COAP_ALL_NODES_IPV6_SL_MC_ADDR, CoapConstants.COAP_DEFAULT_PORT);
}
...
...
ws4d-jcoap/pom.xml
View file @
673fa682
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.ws4d.jcoap
</groupId>
<artifactId>
jcoap-core
</artifactId>
<version>
1.1.
4
</version>
<version>
1.1.
5
</version>
<name>
jCoAP
</name>
<licenses>
<license>
...
...
ws4d-jcoap/src/org/ws4d/coap/core/connection/BasicCoapSocketHandler.java
View file @
673fa682
...
...
@@ -116,10 +116,20 @@ public class BasicCoapSocketHandler implements CoapSocketHandler {
try
{
this
.
dgramSocket
.
joinGroup
(
InetAddress
.
getByName
(
CoapConstants
.
COAP_ALL_NODES_IPV6_LL_MC_ADDR
));
}
catch
(
Exception
e1
){
logger
.
warn
(
"IPv6 link local multicast not available. Continuing without."
);
logger
.
debug
(
e1
.
getLocalizedMessage
());
}
try
{
this
.
dgramSocket
.
joinGroup
(
InetAddress
.
getByName
(
CoapConstants
.
COAP_ALL_NODES_IPV6_SL_MC_ADDR
));
}
catch
(
Exception
e1
){
logger
.
warn
(
"IPv6 site local multicast not available. Continuing without."
);
logger
.
debug
(
e1
.
getLocalizedMessage
());
}
try
{
this
.
dgramSocket
.
joinGroup
(
InetAddress
.
getByName
(
CoapConstants
.
COAP_ALL_NODES_IPV4_MC_ADDR
));
}
catch
(
Exception
e1
){
logger
.
warn
(
"
M
ulticast
socket could not be opened
. Continuing without
Multicast support
."
);
logger
.
warn
(
"
IPv4 m
ulticast
not available
. Continuing without."
);
logger
.
debug
(
e1
.
getLocalizedMessage
());
}
this
.
workerThread
=
new
WorkerThread
();
...
...
ws4d-jcoap/test/org/ws4d/coap/core/test/PlugTest.java
View file @
673fa682
...
...
@@ -132,7 +132,7 @@ public class PlugTest {
* allowed/disallowed
* GET POST PUT DELETE
*
* -> 2*2*2*
5
=
40
Tests
* -> 2*2*2*
4
=
32
Tests
*/
//RELIABLE GET EXISTING ALLOWED
...
...
Björn Butzin
@bjoern.butzin
mentioned in issue
#9
·
Jan 14, 2019
mentioned in issue
#9
mentioned in issue #9
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment