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


Java Serializer.registerClass方法代码示例

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


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

示例1: main

import com.jme3.network.serializing.Serializer; //导入方法依赖的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

示例2: main

import com.jme3.network.serializing.Serializer; //导入方法依赖的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

示例3: main

import com.jme3.network.serializing.Serializer; //导入方法依赖的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

示例4: main

import com.jme3.network.serializing.Serializer; //导入方法依赖的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

示例5: registerData

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
private static void registerData() {
    Serializer.registerClass(ChatData.class);
    Serializer.registerClass(ViewData.class);
    
    Serializer.registerClass(ActionRunMess.class);
    Serializer.registerClass(ActorSpeakMess.class);
    Serializer.registerClass(ChatSendMess.class);
    Serializer.registerClass(ChatShopMess.class);
    Serializer.registerClass(MessageMess.class);
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:11,代码来源:Init.java

示例6: Main

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public Main() {
    Properties properties = new Properties();
    try {
        properties.load(getClass().getClassLoader().
                getResourceAsStream("resources/net/client/network.properties"));
        magicallyousClient = Network.connectToServer(
                properties.getProperty("server.name", "Magicallyous Server"),
                Integer.parseInt(properties.getProperty("server.version", "1")),
                properties.getProperty("server.address", "localhost"),
                Integer.parseInt(properties.getProperty("server.port", "5465")), 
                Integer.parseInt(properties.getProperty("server.port", "5466")));
        // register serializable messages classes
        Serializer.registerClass(WelcomeMessage.class);
        Serializer.registerClass(AccountRegisterMessage.class);
        Serializer.registerClass(MagicallyousAccount.class);
        Serializer.registerClass(ServerServiceOutcomeMessage.class);
        Serializer.registerClass(LoginRequestMessage.class);
        Serializer.registerClass(LoginResponseMessage.class);
        Serializer.registerClass(PlayerNetInputMessage.class);
        // register listeners
        clientMessageListener = new ClientMessageListener();
        magicallyousClient.addMessageListener(clientMessageListener, 
                WelcomeMessage.class, PlayerNetInputMessage.class);
        magicallyousClient.start();
        System.out.println("Application connected to server " 
                + "name: " + properties.getProperty("server.name") 
                + " address: " + properties.getProperty("server.address") 
                + " port: " + properties.getProperty("server.port"));
    } catch (IOException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
    }
    actualSceneName = magicallyousSceneName;
}
 
开发者ID:duodecimo,项目名称:magicallyous,代码行数:34,代码来源:Main.java

示例7: init

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public static boolean init(String host, int port)
{
	Serializer.registerClass(UpdateMessage.class);
	Serializer.registerClass(AGVData.class);
       Serializer.registerClass(TruckCraneData.class);
       Serializer.registerClass(TruckSpawnData.class);
       Serializer.registerClass(StorageCranePickupData.class);
       Serializer.registerClass(SeaShipCraneData.class);
       Serializer.registerClass(BargeCraneData.class);
       
       Serializer.registerClass(SeaShipSpawnData.class);
       Serializer.registerClass(BargeSpawnData.class);
       Serializer.registerClass(ContainerData.class);
       Serializer.registerClass(StorageCraneDropoffData.class);
       
       Serializer.registerClass(InitMessage.class);
	try
	{
		client = Network.connectToServer(host, port);
	}
	catch (Exception e)
	{
		System.out.println(e);
		return false;
	}
	client.addMessageListener(new ClientListener());
	client.start();
	return true;
}
 
开发者ID:megagorilla,项目名称:Containing,代码行数:30,代码来源:ConnectionManager.java

示例8: initialize

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
/**
 * Create and start the server.
 * 
 * @param port
 * @return true if succesful, false otherwise
 */
public static boolean initialize(int port) {
	Serializer.registerClass(UpdateMessage.class);
	Serializer.registerClass(AGVData.class);
	Serializer.registerClass(TruckCraneData.class);
	Serializer.registerClass(TruckSpawnData.class);
	Serializer.registerClass(StorageCranePickupData.class);
	Serializer.registerClass(SeaShipCraneData.class);
	Serializer.registerClass(BargeCraneData.class);

	Serializer.registerClass(SeaShipSpawnData.class);
	Serializer.registerClass(BargeSpawnData.class);
	Serializer.registerClass(ContainerData.class);
	Serializer.registerClass(StorageCraneDropoffData.class);

	Serializer.registerClass(InitMessage.class);
	try {
		server = Network.createServer(port);
	}
	catch (Exception e) {
		System.err.println(e);
		return false;
	}
	server.addConnectionListener(new ConnectionListener());
	server.start();
	return true;
}
 
开发者ID:megagorilla,项目名称:Containing,代码行数:33,代码来源:ConnectionManager.java

示例9: startClient

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public static void startClient() {
	Serializer.registerClass(Event.class);
	try {
		Thread.sleep(1000);
		client = Network.connectToServer("localhost", OpenRTSServer.PORT);
		client.addClientStateListener(new ClientStateListener());
		client.addMessageListener(new MessageListener(), Event.class);
	} catch (IOException | InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	client.start();
	
	EventManager.register(instance);
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:16,代码来源:ClientManager.java

示例10: simpleInitApp

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
@Override
public void simpleInitApp() {
	try {
		myServer = Network.createServer(PORT, PORT);
		myServer.addMessageListener(new MessageListener(), Event.class);
		myServer.addConnectionListener(new ConnectionListener());
		myServer.start();
		logger.info("Server listening at :" + PORT);

	} catch (IOException e) {
		e.printStackTrace();
	}
	Serializer.registerClass(Event.class);
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:15,代码来源:OpenRTSServer.java

示例11: registerMessages

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
/**
 * Register all message types with the serialiser.
 */
public static void registerMessages()
{
  Serializer.registerClass(GameStartMessage.class);
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:8,代码来源:MessageRegistry.java

示例12: initializeClasses

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public static void initializeClasses() {
    // Doing it here means that the client code only needs to
    // call our initialize. 
    Serializer.registerClass(ChatMessage.class);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:TestChatServer.java

示例13: simpleInitApp

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
@Override
public void simpleInitApp() {
    MessageUtils.registerDataClasses();
    MessageUtils.registerMessages();

    Serializer.registerClass(ReplayHeader.class);
    Serializer.registerClass(ReplayCmdData.class);
    Serializer.registerClass(ReplayData.class);

    Globals.assets = getAssetManager();
    Globals.app = this;
    world = new World();
    game = new ServerGame();
    physics = new BulletAppState();
    physics.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    flyCam.setEnabled(false);

    int port = Settings.get().General().getPort();
    if (port <= 0 || port > 65535) {
        System.out.println("Port must be between 0 and 65535");
        System.exit(1);
    }

    try {
        server = new UdpServer("Arkhados", 42, new MyUdpKernel(port));
        server.start();
    } catch (IOException ex) {
        System.exit(1);
    }

    receiver = new DefaultReceiver();
    server.addMessageListener(receiver, OneTrueMessage.class);

    sender = new RecordingServerSender(server);
    AbstractBuff.setSender(sender);

    receiver.registerCommandHandler(sender);

    listenerManager = new ServerNetListener(this, server);
    sync = new Sync(this);

    ServerInput input = ServerInput.get();

    receiver.registerCommandHandler(listenerManager);
    receiver.registerCommandHandler(input);
    receiver.registerCommandHandler(sync);

    stateManager.attach(sender);
    stateManager.attach(receiver);
    stateManager.attach(sync);
    stateManager.attach(world);
    stateManager.attach(game);
    stateManager.attach(physics);

    sender.setWorld(world);
    // Accuracy should be > 45 or projectiles might "disappear" before
    // exploding. This is because of FogOfWar
    physics.getPhysicsSpace().setAccuracy(1f
            / Settings.get().General().getPhysicsTicksPerSecond());                
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:61,代码来源:ServerMain.java

示例14: registerDataClasses

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public static void registerDataClasses() {
    Serializer.registerClass(PlayerData.class);
    Serializer.registerClass(PlayerRoundStats.class);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:5,代码来源:MessageUtils.java

示例15: registerMessages

import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public static void registerMessages() {
    Serializer.registerClass(OneTrueMessage.class);
    Serializer.registerClass(OtmIdCommandListPair.class);

    Serializer.registerClass(Ack.class);
    Serializer.registerClass(CmdTopicOnly.class);

    // <Lobby>
    Serializer.registerClass(CmdServerLogin.class);
    Serializer.registerClass(CmdClientLogin.class);
    Serializer.registerClass(CmdClientSettings.class);
    Serializer.registerClass(CmdPlayerDataTable.class);
    Serializer.registerClass(ChatMessage.class);
    Serializer.registerClass(CmdSelectHero.class);
    Serializer.registerClass(CmdPlayerStatusChange.class);
    Serializer.registerClass(CmdTeamOptions.class);
    Serializer.registerClass(CmdSelectTeam.class);
    Serializer.registerClass(CmdTeamAcceptance.class);
    // </Lobby>

    // <Sync>
    Serializer.registerClass(CmdAddEntity.class);
    Serializer.registerClass(CmdRemoveEntity.class);
    Serializer.registerClasses(StateData.class, CharacterSyncData.class,
            GenericSyncData.class, ProjectileSyncData.class);
    Serializer.registerClass(EliteSoldierSyncData.class);
    Serializer.registerClass(CmdStartCastingSpell.class);
    Serializer.registerClass(CmdSetCooldown.class);
    Serializer.registerClass(CmdAction.class);
    Serializer.registerClass(CmdEndAction.class);
    Serializer.registerClass(CmdBuff.class);
    Serializer.registerClass(CmdBuffStacks.class);
    // </Sync>

    // <UserCommands>
    Serializer.registerClass(CmdUcCastSpell.class);
    Serializer.registerClass(CmdUcWalkDirection.class);
    Serializer.registerClass(CmdUcMouseTarget.class);
    // </UserCommands>

    // <Other>
    Serializer.registerClass(CmdSetPlayersCharacter.class);
    Serializer.registerClass(BattleStatisticsResponse.class);
    Serializer.registerClass(CmdPlayerKill.class);
    Serializer.registerClass(CmdWorldEffect.class);        
    // </Other>        

    Serializer.registerClass(ConnectionMessageContainer.class);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:50,代码来源:MessageUtils.java


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