예제 #1
0
    static IEnumerator HandlePackage()
    {
        while (connected)
        {
            lock (packageQueue)
            {
                if (packageQueue.Count > 0)
                {
                    Package package = packageQueue.Dequeue();
                    if (callbackDict.ContainsKey(package.type))
                    {
                        List <NetworkCallback> callbackList = callbackDict[package.type];

                        for (int i = callbackList.Count - 1; i >= 0; i--)
                        {
                            NetworkCallback callback = callbackList[i];
                            callback.func(package.data);
                            if (callback.isDelete)
                            {
                                callbackList.RemoveAt(i);
                            }
                        }
                    }
                }
            }
            yield return(null);
        }
        DisconnectedUI.Show();
    }
예제 #2
0
    public static void Notify(ENUM_CMD cmd, object data)
    {
        if (callbackDict.ContainsKey(cmd))
        {
            List <NetworkCallback> callbackList = callbackDict[cmd];

            for (int i = callbackList.Count - 1; i >= 0; i--)
            {
                NetworkCallback callback = callbackList[i];
                callback.func(data);
                if (callback.isDelete)
                {
                    callbackList.RemoveAt(i);
                }
            }
        }
    }