Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EGI avatar functionality #3

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

knuton
Copy link
Contributor

@knuton knuton commented Jan 14, 2021

Questions

  • How to get a MonoBehaviour to run as a "service"?
  • Can we run the WebSocket client directly from Hardware.cs? Its
    DispatchMessageQueue function seems to need to be called
    periodically, so something seems to need to actively drive it.

Plans

  • Handle signals as far down as possible. Probably worth refactoring the
    jslib to also send signals into Unity as strings, can reuse parsing
    code for both JS EGI and avatar EGI then.

Questions

- How to get a MonoBehaviour to run as a "service"?
- Can we run the WebSocket client directly from `Hardware.cs`? Its
  `DispatchMessageQueue` function seems to need to be called
  periodically, so something seems to need to actively drive it.

Plans

- Handle signals as far down as possible. Probably worth refactoring the
  jslib to also send signals into Unity as strings, can reuse parsing
  code for both JS EGI and avatar EGI then.
@sutee9
Copy link
Owner

sutee9 commented Jan 14, 2021

Answers:

  • How to get a MonoBehaviour to run as a "service"? --> You can't directly, but one could write an editor extension, that sets up a web socket connection to do that. I'm not very good at that however, but I'll have a look.
  • Can we run the WebSocket client directly from Hardware.cs? Its DispatchMessageQueue function seems to need to be called periodically, so something seems to need to actively drive it --> Yes, see below. Implement it as a singleton.

Detail:
In WebsocketAvatar, mache alle events non-static, und adde diese boilerplate um es ein Singleton zu machen. So musst du kein Monobehaviour / GameObject zur szene hinzufügen, und es läuft einfach.

    private event Hardware.DirectionCallback _onStep;
    private event Hardware.DirectionCallback _onRelease;
    private event Hardware.PlateCallback _onSensoState;

    public static WebsocketAvatar Instance
    {
        get
        {
            if (_instance == null)
            {
                _instance = FindObjectOfType<WebsocketAvatar>();
                if (_instance == null)
                {
                    GameObject obj = new GameObject();
                    obj.name = "Senso-LiveConnection";
                    _instance = obj.AddComponent<WebsocketAvatar>();
                }
            }
            return _instance;
        }
    }
    private static WebsocketAvatar _instance;

    protected void Awake()
    {
        //Check the singleton is unique
        if (_instance == null)
        {
            _instance = WebsocketAvatar.Instance;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }

In Hardware.cs, ändere den Aufruf zu
WebsocketAvatar.Instance.Register(OnStep, OnRelease, OnSensoState);

URL / Raum Problem ist damit noch nicht gelöst, aber bekommen wir noch hin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants