Example #1
0
        private void ProcessMessage(ref uOSC.Message message)
        {
            //メッセージアドレスがない、あるいはメッセージがない不正な形式の場合は処理しない
            if (message.address == null || message.values == null)
            {
                StatusMessage = "Bad message.";
                return;
            }

            if (manager.receiver.isLoading)
            {
                //ローカル読込中は処理しない
                return;
            }

            if (manager.status.DVRC_AuthState != "AUTHENTICATION_OK")
            {
                //ログインしていない場合は受け付けない
                return;
            }

            if (message.address == "/VMC/Ext/Remote" &&
                (message.values[0] is string) && //service
                (message.values[1] is string)    //json
                )
            {
                string service = message.values[0] as string;
                string json    = message.values[1] as string;

                if (service == "dmmvrconnect")
                {
                    var connect = JsonUtility.FromJson <dmmvrconnect>(json);
                    if (user_id != connect.user_id || avatar_id != connect.avatar_id)
                    {
                        user_id   = connect.user_id;
                        avatar_id = connect.avatar_id;

                        //メインスレッドに渡す
                        synchronizationContext.Post(async _ => {
                            Debug.Log("Avatar loading from Connect...");
                            var current_user = await Authentication.Instance.Okami.GetCurrentUserAsync();
                            if (user_id == current_user.id)
                            {
                                var avatar = await Authentication.Instance.Okami.GetAvatarAsync(current_user.id, avatar_id);
                                Debug.Log(avatar);
                                if (avatar != null)
                                {
                                    await manager.LoadAvatarFromDVRSDK(avatar);
                                }
                                else
                                {
                                    Debug.LogError("Avatar loading from Connect... Failed!");
                                }
                                Debug.Log("Load from connect OK");
                            }
                            else
                            {
                                Debug.Log("User id unmatch");
                            }
                        }, null);
                    }
                }
                else
                {
                    StatusMessage = "Unknown service: " + service;
                }
            }
        }