Added a service for opening browser windows

This commit is contained in:
Ziggeh
2014-07-06 01:30:18 +02:00
parent 46a36badad
commit a35d707c78
4 changed files with 124 additions and 0 deletions
+4
View File
@@ -65,6 +65,7 @@ import services.DevService;
import services.EntertainmentService;
import services.GroupService;
import services.housing.HousingService;
import services.BrowserService;
import services.InstanceService;
import services.LoginService;
import services.LootService;
@@ -204,6 +205,7 @@ public class NGECore {
public PlayerCityService playerCityService;
public ReverseEngineeringService reverseEngineeringService;
public PetService petService;
public BrowserService browserService;
// Login Server
public NetworkDispatch loginDispatch;
@@ -531,6 +533,8 @@ public class NGECore {
playerCityService.loadCities();
retroService.run();
browserService = new BrowserService(this);
didServerCrash = false;
System.out.println("Started Server.");
cleanupCreatureODB();
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package protocol.swg;
import java.nio.ByteOrder;
import java.util.Vector;
import org.apache.mina.core.buffer.IoBuffer;
import resources.common.Opcodes;
import services.sui.SUIWindowComponent;
public class LaunchBrowserMessage extends SWGMessage{
private String URL;
public LaunchBrowserMessage(String URL) {
this.URL = URL;
}
public void deserialize(IoBuffer data) {
}
public IoBuffer serialize() {
IoBuffer result = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN);
result.setAutoExpand(true);
result.putShort((short) 2);
result.putInt(Opcodes.LaunchBrowserMessage);
result.put(getAsciiString(URL));
int size = result.position();
result = IoBuffer.allocate(size).put(result.array(), 0, size);
return result.flip();
}
}
+1
View File
@@ -90,5 +90,6 @@ public class Opcodes {
public static final int CancelLiveAuctionMessage = CRC.StringtoCRC("CancelLiveAuctionMessage");
public static final int BidAuctionMessage = CRC.StringtoCRC("BidAuctionMessage");
public static final int RetrieveAuctionItemMessage = CRC.StringtoCRC("RetrieveAuctionItemMessage");
public static final int LaunchBrowserMessage = CRC.StringtoCRC("LaunchBrowserMessage");
}
+60
View File
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package services;
import java.util.Map;
import protocol.swg.LaunchBrowserMessage;
import resources.objects.creature.CreatureObject;
import main.NGECore;
import engine.resources.service.INetworkDispatch;
import engine.resources.service.INetworkRemoteEvent;
public class BrowserService implements INetworkDispatch {
private NGECore core;
public BrowserService(NGECore core) {
this.core = core;
}
public void sendBrowserWindow(CreatureObject creature, String URL) {
URL = URL.toLowerCase();
if( URL.contains("http://"))
URL.replace("http://", "");
LaunchBrowserMessage launchBrowserMessage = new LaunchBrowserMessage(URL);
creature.getClient().getSession().write(launchBrowserMessage.serialize());
}
@Override
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> arg0, Map<Integer, INetworkRemoteEvent> arg1) {
}
@Override
public void shutdown() {
}
}