11package jsc .jConnection ;
22
3+ import jsc .jEventManager .JEventManager ;
34import jsc .jMessageHandler .JMessageConsumer ;
45
56import java .io .DataInputStream ;
@@ -22,12 +23,26 @@ public JConnection(Socket socket, JMessageConsumer msgDecoder) throws IOExceptio
2223messageDecoder =msgDecoder ;
2324 }
2425
25- public JConnection (){}
26+ public JConnection (Socket socket )throws IOException {
27+ this (socket ,new JEventManager ());
28+ }
29+
30+ public JConnection (){
31+ messageDecoder =new JEventManager ();
32+ }
2633
2734public JConnection (String connectionIP ,int connectionPort ,JMessageConsumer msgDecoder )throws IOException {
2835this (new Socket (connectionIP ,connectionPort ),msgDecoder );
2936 }
3037
38+ public JConnection (String connectionIP ,int connectionPort )throws IOException {
39+ this (connectionIP ,connectionPort ,new JEventManager ());
40+ }
41+
42+ public JConnection (String connectionID ,Socket socket )throws IOException {
43+ this (connectionID ,socket ,new JEventManager ());
44+ }
45+
3146public JConnection (String connectionID ,Socket socket ,JMessageConsumer msgDecoder )throws IOException {
3247this (socket ,msgDecoder );
3348setConnectionID (connectionID );
@@ -119,6 +134,18 @@ public void setMessageDecoder(JMessageConsumer messageDecoder) {
119134this .messageDecoder =messageDecoder ;
120135 }
121136
137+
138+ /**
139+ * Only applicable when @see #messageDecoder is set to JEventManager
140+ * @return JEventConsumer
141+ */
142+ public JEventManager getJEventManager (){
143+ if (messageDecoder instanceof JEventManager ){
144+ return (JEventManager )messageDecoder ;
145+ }
146+ return null ;
147+ }
148+
122149public void accept (String msg ) {
123150if (messageDecoder !=null ){
124151messageDecoder .accept (msg );