aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/TrackerServer.java
diff options
context:
space:
mode:
authorwilliamchitto <williamchitto@gmail.com>2012-07-31 08:08:53 -0300
committerwilliamchitto <williamchitto@gmail.com>2012-07-31 08:08:53 -0300
commitf5e305c4ea89210a2e4daffa4e947acdc440fbe7 (patch)
treeebc542944483e95c9b7374217690fc7bba38ff33 /src/org/traccar/TrackerServer.java
parentd9c99fafa2e4d581f473029144aec495cb94bb62 (diff)
downloadtrackermap-server-f5e305c4ea89210a2e4daffa4e947acdc440fbe7.tar.gz
trackermap-server-f5e305c4ea89210a2e4daffa4e947acdc440fbe7.tar.bz2
trackermap-server-f5e305c4ea89210a2e4daffa4e947acdc440fbe7.zip
adicionando classes de testes
Diffstat (limited to 'src/org/traccar/TrackerServer.java')
-rw-r--r--src/org/traccar/TrackerServer.java125
1 files changed, 70 insertions, 55 deletions
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index da889d0a3..f4830d778 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -16,6 +16,7 @@
package org.traccar;
import java.net.InetSocketAddress;
+import java.util.Iterator;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
@@ -29,60 +30,74 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
*/
public class TrackerServer extends ServerBootstrap {
- /**
- * Initialization
- */
- private void init(Integer port, Integer threadPoolSize) {
-
- setPort(port);
-
- // Create channel factory
- setFactory(new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(),
- Executors.newCachedThreadPool()));
- }
-
- public TrackerServer(Integer port) {
- init(port, 1);
- }
-
- /**
- * Server port
- */
- private Integer port;
-
- public Integer getPort() {
- return port;
- }
-
- private void setPort(Integer newPort) {
- port = newPort;
- }
-
- /**
- * Opened channels
- */
- private ChannelGroup allChannels = new DefaultChannelGroup();
-
- public ChannelGroup getChannelGroup() {
- return allChannels;
- }
-
- /**
- * Start server
- */
- public void start() {
- Channel channel = bind(new InetSocketAddress(getPort()));
- getChannelGroup().add(channel);
- }
-
- /**
- * Stop server
- */
- public void stop() {
- ChannelGroupFuture future = getChannelGroup().close();
- future.awaitUninterruptibly();
- getFactory().releaseExternalResources();
- }
+ /**
+ * Initialization
+ */
+ private void init(Integer port, Integer threadPoolSize) {
+
+ setPort(port);
+
+ // Create channel factory
+ setFactory(new NioServerSocketChannelFactory(
+ Executors.newCachedThreadPool(),
+ Executors.newCachedThreadPool()));
+ }
+
+ public TrackerServer(Integer port) {
+ init(port, 1);
+ }
+
+ /**
+ * Server port
+ */
+ private Integer port;
+
+ public Integer getPort() {
+ return port;
+ }
+
+ private void setPort(Integer newPort) {
+ port = newPort;
+ }
+
+ /**
+ * Opened channels
+ */
+ private ChannelGroup allChannels = new DefaultChannelGroup();
+
+ public ChannelGroup getChannelGroup() {
+ return allChannels;
+ }
+
+ public void mandaMSG() {
+
+ /* for (Iterator it = this.getChannelGroup().iterator(); it.hasNext();) {
+ Channel chanel = (Channel) it.next();
+ System.out.println(chanel.getRemoteAddress());
+ if(chanel.getRemoteAddress() !=null)
+ this.getChannelGroup().write("OI AMIGO", chanel.getRemoteAddress());
+
+ }
+*/
+ // System.out.println(type.getPort());
+
+ }
+
+ /**
+ * Start server
+ */
+ public void start() {
+ Channel channel = bind(new InetSocketAddress(getPort()));
+ getChannelGroup().add(channel);
+ }
+
+ /**
+ * Stop server
+ */
+ public void stop() {
+ ChannelGroupFuture future = getChannelGroup().close();
+ future.awaitUninterruptibly();
+ getFactory().releaseExternalResources();
+ }
}