lwb
2020-11-02 01dd455fc77f47fb5c4ccd7bb850368dee06d9e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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<Integer, ICommand> ();
 
    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 ignored) {
 
        }
    }
 
}