本文整理汇总了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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例11: registerMessages
import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
/**
* Register all message types with the serialiser.
*/
public static void registerMessages()
{
Serializer.registerClass(GameStartMessage.class);
}
示例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);
}
示例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());
}
示例14: registerDataClasses
import com.jme3.network.serializing.Serializer; //导入方法依赖的package包/类
public static void registerDataClasses() {
Serializer.registerClass(PlayerData.class);
Serializer.registerClass(PlayerRoundStats.class);
}
示例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);
}