| | |
| | | package com.secondworld.universalsdk; |
| | | |
| | | import com.secondworld.universalsdk.command.ICommand; |
| | | |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | public class H2EngineSDK { |
| | | |
| | | public static HashMap<Integer, ICommand> allCommand = new HashMap(); |
| | | |
| | | public static void init() { |
| | | |
| | | } |
| | | |
| | | private static void AddCommand(ICommand command) { |
| | | allCommand.put(command.getCode(), command); |
| | | } |
| | | |
| | | //unity 发来的消息 |
| | | public static void HandleUnityMessage(String json) { |
| | | try { |
| | | JSONObject _json = new JSONObject(json); |
| | | int code = _json.getInt("code"); |
| | | ICommand command = allCommand.get(code); |
| | | if (command == null) { |
| | | return; |
| | | } |
| | | command.process(json); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | } |