51 Commits

Author SHA1 Message Date
Paul Speed
c6768dc724 Added some additional finest logging. 2016-01-23 05:38:23 -05:00
Paul Speed
b28f7e9293 Removing a println I had for testing something else.
Added some gating to the endpoint closure to try to delay
some NPE I'm seeing caused be a race condition somewhere when
client and server in the same VM and shutting down at the same
time.
2016-01-16 04:24:02 -05:00
Paul Speed
ac672df63a Fixes to keep the kernel adapter threads from hanging.
Closing the underlying kernel didn't wake up any readers
and so the read() operation in the adapter was never returning.
KernelAdapter.close() was modified to call join() after closing
the underlying kernel so that the method won't complete until
all of the threads are done.
Then the kernels were modified to wakeup the readers (and this
is now standardized in a base class method) so that they don't
hang forever.
2016-01-16 03:28:10 -05:00
Paul Speed
c38a050f61 Added some trace level logging to field serializer. 2015-12-31 04:28:03 -05:00
Paul Speed
ac5cc5312b Added some additional information to the bad constants exception.
Only of marginal utility but it was a nice sanity check.
2015-12-31 04:27:05 -05:00
Paul Speed
a0569b340d Fixed a bug caused by generic registration of the enum class
but it could catch the user unaware for any registered non-leaf
class.  When a class has a field of a specific final type then
the type information is implicit in the outer object... and
the proper serialization information can be written.  It is then
sometimes useful to register a generic serializer for something
like Enum to catch these cases.  However, there are many times where
the type cannot be implicitly known and so must be specifically
registered.  Prior to this fix, having a generic Enum serializer
registered would cause problems on the reading end because it
wouldn't know what real enum class to use.
Now we catch the issue on the write side where enough information
is known to properly report this to the user.  Only a few Bothans
died to bring this info.
2015-12-31 04:26:22 -05:00
Paul Speed
05587ab387 Modified to avoid closing the connection if it is already
closed.  Certain race conditions can cause this to happen
during whole-server shutdown.
2015-12-31 04:23:11 -05:00
Paul Speed
6cb691592d Fixed two potential race conditions in the DefaultClient.
In one case, closing a client while it was already closing on
another thread (say because the server is shutting down and
you are exiting at the same time) would cause an NPE if you
caught it just right.  Now the thing checking and setting the
connection state is synchronized to avoid the race.

The other more subtle one was caused by sending out the 'connected'
event before the services were all started.  It's quite common for
application code to start doing stuff when the 'connected' event comes
through like sending messages and stuff.  If the services hadn't been
fully started then even the serializers might not be registered yet...
and that = bad.

Now the client doesn't send the 'connected' event until the services
are started.  This should be safe and one could argue that it's more
'correct' but there is some small chance that it screws up certain
use-cases.  However, if a real use-case comes up that's not solved by
a service then we can always add some kind of prestarted event.
2015-12-26 17:56:31 -05:00
Paul Speed
d8d7d061f6 Small formatting change. 2015-12-26 17:51:47 -05:00
Paul Speed
0bfabacef6 Small formatting change. 2015-12-26 17:49:37 -05:00
Paul Speed
d241a9a235 Added a couple more bracketing log messages just to confirm
my own sanity.
Some small formatting changes.
2015-12-26 17:45:58 -05:00
Paul Speed
ab0628c070 Fixed a typo in an exception message. 2015-12-26 17:42:15 -05:00
Paul Speed
50b2f76bdf Modified the FieldSerializer to support classes with non-public no-arg constructors.
Finally we can end the tyranny of exposing dangerous public constructors in the
name of a cheap serialization.
2015-12-24 03:29:36 -05:00
Paul Speed
98194e83aa Modified the RPC layer to pass exceptions over the wire
if they are serializable.  They are still wrapped but at
least the original exception is intact if callers want to 
peel it out.
2015-12-22 05:33:44 -05:00
Paul Speed
14e84a4dd7 Added a constructor that just takes the service's
default channel.
2015-12-05 04:15:48 -05:00
Paul Speed
99742a76f2 Added additional trace logging. 2015-12-05 04:15:28 -05:00
Paul Speed
15afcfb735 Added the error information to the toString() if
there is error information to show.
2015-12-05 04:05:49 -05:00
Paul Speed
197ed33c9e Added some missing @Overrides and finals. 2015-11-22 05:23:24 -05:00
Paul Speed
388a8a8bd7 Added a bunch of lower level logging that can be
used to either watch traffic or debug serialization
issues, etc..
Went ahead and instrumented the service manager while
I was at it... and fixed a potential NPE in the AbstractService's
toString() method.
Fixed a bug in the DefaultClient where it couldn't be shutdown
if attempted before the services had been started.
2015-11-22 05:13:12 -05:00
Paul Speed
3a4624a5fe Added a bunch of javadoc and changed the names of one of the
method sets to be a little less confusing.
2015-11-16 02:38:45 -05:00
Paul Speed
95aa2d72d0 Added a basic RMI service that uses the RPC service.
I'll add some more javadoc in a sec.
2015-11-16 02:04:31 -05:00
Paul Speed
95603c46c4 Added a better check. The old one had the side-effect
of registering the class if it wasn't already registered.
2015-11-16 02:03:27 -05:00
Paul Speed
dfe4b083f0 Added a check to try and detect the case where a server and
a client are running on the same instance.  This should cover
99% of the cases where this would come up... and the others
can't really use this service anyway and so must disable it.
2015-11-15 02:24:18 -05:00
Paul Speed
4b2f361026 Modified to skip registering the message classes if they are
already registered.  This avoids one of the issues of a client
running in the same JVM as a server that already registered these
classes.  This was the easy fix.
2015-11-15 02:22:53 -05:00
AlrikG
7b6a742f0f Update GZIPSerializer.java 2015-06-22 17:12:12 +02:00
AlrikG
2cf7d9eb5a Update GZIPSerializer.java 2015-06-22 17:11:50 +02:00
Alrik
1eedfa5a5f - fix GZIP and ZIP serializer copying the whole temporary buffer instead
of only the part where the data was written.
2015-06-22 17:04:50 +02:00
Paul Speed
4bd774a653 Created an abstract hosted connection service that has
the autohost, start/stopHostingOnConnection support built
into it.  This is a very common things for connection based
services and I got tired of cutting/pasting it all the time.
RpcHostedService was modified to extend this base class
instead of the more basic one.
2015-05-28 01:10:44 -04:00
Paul Speed
9a8aa3b394 Prevent an NPE for null parameter arrays. 2015-05-11 02:28:56 -04:00
Paul Speed
42105f4c4b Just some whitespace changes. 2015-05-02 00:41:47 -04:00
Paul Speed
c1670e7509 Added the read class ID to the bad deserialize
exception.  Two things can cause bad reads:
1) bad data in the stream... in which the extra info
   is useless or confusing.
2) unregistered classes or bad timing, either way,
   knowing the message type ID might be useful.
2015-05-02 00:39:41 -04:00
Paul Speed
58313c271d Added a better comment as to why we have to check
the channels even though the negative channels would
pass through as the default channels just fine.
The key is avoiding UDP calls... they will get
translated into a regular send.
2015-05-02 00:38:24 -04:00
Paul Speed
c1dc819953 Added the ability to put the serializer registry
in "read only" mode.  Modified the SerializerRegistrationMessage
to put the serializer registry into read only after
it compiles the message so that the server won't accidentally
register messages after they've been compiled.
2015-05-02 00:35:15 -04:00
Paul Speed
33d21c2de3 Added an isStarted() method to Client. 2015-05-01 02:26:33 -04:00
Paul Speed
323daeb94f Added a getRpcConnection() method to expose the underlying
RPC support.
2015-05-01 02:25:24 -04:00
Paul Speed
a77ed52777 Added getServer() and getClient() convenience methods. 2015-05-01 02:24:52 -04:00
Paul Speed
e000d83ae7 Fixed a stack overflow exception if one println()'ed
a service... since most service managers print their
services in their own toString().
2015-05-01 02:24:16 -04:00
Paul Speed
57dbf384a2 Modified the DefaultServer to send a second client
info message to indicate that all of the local hosted
services have been notified about the new connection.
Modified DefaultClient to wait to start its services
until it has seen this second message.

Client services may want to send things to the server during
their start() method but it's important that things like
the serializer registry service has already processed its
messages or any sends might fail.  The client generally has
the luxury of being able to register handlers/listeners/etc
during initialize where as the server must do this when the
connection arrives.  So it seems reasonable to delay client
service start() until all of the server-side hosted services
have had a chance to initialize themselves.
2015-05-01 02:15:41 -04:00
Paul Speed
7bea2cc9c7 Fixed a missing import. 2015-04-26 03:10:47 -04:00
Paul Speed
96dab5f561 Allow remote calls to be made on the default channel
instead of just custom channels.  Custom channels are
0-max channel while -1 indicates the default send().
2015-04-26 02:28:38 -04:00
Paul Speed
dd65580bf3 Pre-register the inner class as well. A cut paste
error from my originals.
2015-04-26 02:27:27 -04:00
Paul Speed
8b34e4890a Fixed a comment to be more accurate with respect
to handler method argument types.
Fixed a small bug in how auto-detect worked.  It
was too greedy in looking for two-argument methods
and would somehow allow methods that took a first
argument that was not a connection type.
2015-04-26 02:26:47 -04:00
Paul Speed
1145f99d03 Added a service that will send the server's serializer
registration set to each new client that connects.  The
client-side version of this service will then register them
all.  This means that serialized classes need only be registered
on the server.
I've modified DefaultClient and DefaultServer to register these
services by default because they make other services easier to
write and because they will save people lots of trouble.
I'm 90% sure there are no bad side-effects for people who choose
to continue doing things the old way but it may depend on when
they register their serializers in relations to creating the
client and server objects.
2015-04-26 01:19:38 -04:00
Paul Speed
35155c6b5b Integrated the new service manager stuff with Client and
Server.  (Untested at the moment but straight forward.)
Also fixed a small but silent bug in DefaultServer when
closing out endpoints that were never fully connected.
Garbage was left around in the "connecting" data structure.
2015-04-26 00:57:02 -04:00
Paul Speed
1eb2ba7276 Adding an initial implementation for a service manager module
with custom subclasses and service interfaces for client 
services and server-side services (HostedServices).
This code is a copy and refactoring of code I developed for
Mythruna... it worked there but I haven't tested it yet in its
new form.  Things may change as I integrate this more closely
with the core Client and Server classes.  I wanted to get it
into source control first.
Also included an RPC service implementation which can serve
as the underpinning for other things.
Coming soon: serializer registration service and a simple
RMI service based on the RPC layer.
2015-04-26 00:24:51 -04:00
Paul Speed
9abedf284e Added a message that can be used to compile and
send the serializer registry... and then register
them on the other end.
2015-04-26 00:09:24 -04:00
Paul Speed
c9eaeeea12 Added some message delegator util classes that
makes it easier to handle network messages.  These
delegators can introspect a delegate type to find
message-type specific handler methods.  This mapping
can be done automatically or performed manually.
2015-04-25 23:47:26 -04:00
NemesisMate
2aa6f9f521 Fixed BufferUnderflowException
Fixed the exception occurring when using this serializer. More commented here:

http://hub.jmonkeyengine.org/t/savableserializer-and-client-bufferunderflowexception/31774
2015-02-26 14:41:29 +01:00
shadowislord
f31911f039 * Fix java 8 syntax error in UdpEndpoint 2014-05-31 17:36:49 -04:00
shadowislord
6b12d5c638 * Fix many javadoc errors mostly related to incorrect HTML or missing references 2014-05-31 13:12:46 -04:00