当前位置: 首页>>代码示例>>Java>>正文


Java Client类代码示例

本文整理汇总了Java中com.jme3.network.Client的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Client类属于com.jme3.network包,在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: messageReceived

import com.jme3.network.Client; //导入依赖的package包/类
public void messageReceived(Client source, Message m) {
    ChatMessage chat = (ChatMessage) m;

    System.out.println("Received:" + chat);

    // One of the least efficient ways to add text to a
    // JEditorPane
    chatMessages.append("<font color='#00a000'>" + (m.isReliable() ? "TCP" : "UDP") + "</font>");
    chatMessages.append(" -- <font color='#000080'><b>" + chat.getName() + "</b></font> : ");
    chatMessages.append(chat.getMessage());
    chatMessages.append("<br />");
    String s = "<html><body>" + chatMessages + "</body></html>";
    chatLog.setText(s);

    // Set selection to the end so that the scroll panel will scroll
    // down.
    chatLog.select(s.length(), s.length());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:TestChatClient.java

示例2: main

import com.jme3.network.Client; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException{
    Logger.getLogger("").getHandlers()[0].setLevel(Level.OFF);
    
    Server server = Network.createServer(5110);
    server.start();
    server.addConnectionListener(new TestNetworkStress());

    for (int i = 0; i < 1000; i++){
        Client client = Network.connectToServer("localhost", 5110);
        client.start();

        Thread.sleep(10);
        
        client.close();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:TestNetworkStress.java

示例3: main

import com.jme3.network.Client; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException{
    Serializer.registerClass(PingMessage.class);
    Serializer.registerClass(PongMessage.class);

    Server server = Network.createServer(5110);
    server.start();

    Client client = Network.connectToServer("localhost", 5110);
    client.start();

    server.addMessageListener(new ServerPingResponder(), PingMessage.class);
    client.addMessageListener(new ClientPingResponder(), PongMessage.class);

    System.out.println("Client: Sending ping message..");
    client.send(new PingMessage());
    
    Object obj = new Object();
    synchronized (obj){
        obj.wait();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:TestMessages.java

示例4: main

import com.jme3.network.Client; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {

        Serializer.registerClass(TestMessage.class);

        // Use this to test the client/server name version check
        //Server server = Network.createServer( "bad name", 42, 5110, 5110 );
        Server server = Network.createServer(5110, 5110);
        server.start();

        Client client = Network.connectToServer("localhost", 5110);
        client.start();

        client.addMessageListener(new TestThroughput(false), TestMessage.class);
        server.addMessageListener(new TestThroughput(true), TestMessage.class);

        Thread.sleep(1);

        TestMessage test = new TestMessage();
//        for( int i = 0; i < 10; i++ ) {
        while (true) {
//System.out.println( "sending." );
            client.send(test);
        }

        //Thread.sleep(5000);
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:TestThroughput.java

示例5: messageReceived

import com.jme3.network.Client; //导入依赖的package包/类
@Override
    public void messageReceived(final Client source, final Message m) {
//        LOG.log(Level.INFO, "GameClient receive message={0}", m.getClass().getSimpleName());
        if (listener == null)
            return;
        
        LuoYing.getApp().enqueue(new Callable() {
            @Override
            public Object call() {
                try {
                    listener.clientMessage(GameClient.this, m);
                } catch (Exception e) {
                    LOG.log(Level.SEVERE, "Message error on client!", e);
                }
                return null;
            }
        });
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:19,代码来源:GameClient.java

示例6: main

import com.jme3.network.Client; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException{
    Serializer.registerClass(Savable.class, new SavableSerializer());

    createServer();

    Client client = Network.connectToServer("localhost", 5110);
    client.start();

    ObjectStore store = new ObjectStore(client);
    ServerAccess access = store.getExposedObject("access", ServerAccess.class, true);
    boolean result = access.attachChild("Models/Oto/Oto.mesh.xml");
    System.out.println(result);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:TestRemoteCall.java

示例7: main

import com.jme3.network.Client; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException{
    Serializer.registerClass(SomeObject.class);
    Serializer.registerClass(TestSerializationMessage.class);

    Server server = Network.createServer( 5110 );
    server.start();

    Client client = Network.connectToServer( "localhost", 5110 ); 
    client.start();

    server.addMessageListener(new TestSerialization(), TestSerializationMessage.class);
    client.send(new TestSerializationMessage(true));
    
    Thread.sleep(10000);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:TestSerialization.java

示例8: ObjectStore

import com.jme3.network.Client; //导入依赖的package包/类
public ObjectStore(Client client) {
    this.client = client;
    client.addMessageListener(clientEventHandler, 
            RemoteObjectDefMessage.class,
            RemoteMethodCallMessage.class,
            RemoteMethodReturnMessage.class);
    client.addClientStateListener(clientEventHandler);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:ObjectStore.java

示例9: clientConnected

import com.jme3.network.Client; //导入依赖的package包/类
@Override
public void clientConnected(Client c) {
    if (listener == null)
        return;
    
    LuoYing.getApp().enqueue(new Callable() {
        @Override
        public Object call() throws Exception {
            listener.clientConnected(GameClient.this);
            return null;
        }
    });
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:14,代码来源:GameClient.java

示例10: clientDisconnected

import com.jme3.network.Client; //导入依赖的package包/类
@Override
public void clientDisconnected(final Client c, final DisconnectInfo info) {
    if (listener == null)
        return;
    
    LuoYing.getApp().enqueue(new Callable() {
        @Override
        public Object call() throws Exception {
            listener.clientDisconnected(GameClient.this, info);
            return null;
        }
    });
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:14,代码来源:GameClient.java

示例11: messageReceived

import com.jme3.network.Client; //导入依赖的package包/类
@Override
public void messageReceived(Client source, Message message) {
    if(message instanceof LoginResponseMessage) {
        LoginResponseMessage loginResponseMessage = (LoginResponseMessage) message;
        if(loginResponseMessage.getMagicallyousUser().getId() > 0) {
            // login accepted
            app.setLocalPlayerId(loginResponseMessage.getMagicallyousUser().getId());
            app.setMagicallyousClientConnectionId(loginResponseMessage.getClientId());
            lbCheck.setText("Login successfull!");
        } else {
            app.setLocalPlayerId(new Integer(-1));
            app.setMagicallyousClientConnectionId(new Integer(-1));
            lbCheck.setText("Login failed! You mau try again ...");
        }
    } else if(message instanceof ServerServiceOutcomeMessage) {
        ServerServiceOutcomeMessage serverServiceOutcomeMessage = 
                (ServerServiceOutcomeMessage) message;
        if(serverServiceOutcomeMessage.getService() == 
                ServerServiceOutcomeMessage.Service.ACCOUNT_REGISTER_OK) {
            lbRegCheck.setText("Account registering success!");
            System.out.println("Account registering confirmation received!!!!!");
        } else if(serverServiceOutcomeMessage.getService() == 
                ServerServiceOutcomeMessage.Service.ACCOUNT_REGISTER_FAIL) {
            lbRegCheck.setText("Account registering failure!");
            System.out.println("Account registering failure received!!!!!");
        }
    }
}
 
开发者ID:duodecimo,项目名称:magicallyous,代码行数:29,代码来源:MagicallyousScreenController.java

示例12: messageReceived

import com.jme3.network.Client; //导入依赖的package包/类
@Override
	public void messageReceived(Client source, Message m) {
		if (m instanceof UpdateMessage) {
			this.handleUpdateMessage((UpdateMessage) m);
		}
		if(m instanceof TruckCraneData) {
			this.handleTruckCraneMessage((TruckCraneData) m);
		}
		if (m instanceof TruckSpawnData) {
			this.handleTruckSpawnMessage((TruckSpawnData) m);
		}
//		if (m instanceof StorageCranePickupData){
//			this.handleTrainSpawnMessage((StorageCranePickupData)m);
//		}
//		if(m instanceof TrainCraneData)	{
//			this.handleTrainCraneMessage((TrainCraneData)m);
//		}
		if(m instanceof StorageCranePickupData) {
			this.handleStorageCraneMessage((StorageCranePickupData) m);
		}
		if (m instanceof SeaShipSpawnData) {
			this.handleSeaShipSpawnMessage((SeaShipSpawnData) m);
		}
		if (m instanceof BargeSpawnData) {
			this.handleBargeSpawnMessage((BargeSpawnData) m);
		}
		if (m instanceof SeaShipCraneData) {
			this.handleSeaShipCraneMessage((SeaShipCraneData) m);
		}
		if (m instanceof BargeCraneData) {
			this.handleBargeCraneMessage((BargeCraneData) m);
		}
		if(m instanceof StorageCraneDropoffData)
			this.handleStorageCraneDropoffMessage((StorageCraneDropoffData) m);
		if(m instanceof InitMessage)
			ContainingClient.setSpeed(((InitMessage) m).speed);
	}
 
开发者ID:megagorilla,项目名称:Containing,代码行数:38,代码来源:ClientListener.java

示例13: messageReceived

import com.jme3.network.Client; //导入依赖的package包/类
@Override
public void messageReceived(Client source, Message message) {
	if (message instanceof InputEvent) {
		// do something with the message
		InputEvent helloMessage = (InputEvent) message;
		System.out.println("Client #" + source.getId() + " received: '" + helloMessage.getActionCommand() + "'");
		EventManager.post(helloMessage);
	} // else...
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:10,代码来源:MessageListener.java

示例14: ClientNetListener

import com.jme3.network.Client; //导入依赖的package包/类
/**
 * Constructor.
 * @param application Client's application singleton.
 * @param client Network client connection.
 */
public ClientNetListener(ClientApplication application, Client client) {
  this.application = application;
  client.addClientStateListener(this);
  client.addMessageListener(this, GameStartMessage.class);
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:11,代码来源:ClientNetListener.java

示例15: clientConnected

import com.jme3.network.Client; //导入依赖的package包/类
/**
 * @see ClientStateListener#clientConnected(Client)
 */
public void clientConnected(Client c)
{
  // Nothing to do when connected.
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:8,代码来源:ClientNetListener.java


注:本文中的com.jme3.network.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。