Пример #1
0
        private static void Server_newDeviceConnected(object sender, ConnectivityCore.ConnectionInfo info)
        {
            var puzzle = GameItems.FindPuzzle(info.ID);

            if (puzzle == null)
            {
                Debug($"A device with ID {info.ID} tried to connect. But there is no device with such ID in our system");
            }
            else if (puzzle.Name != info.Name)
            {
                Debug($"A device with ID {info.ID} tried to connect. But its name is {info.Name} whereas our device ID:{info.ID} is named {puzzle.Name}");
            }
            else
            {
                var Zcon = info.Connector;


                Zcon.g_NewErrorFromDevice += detailedDebug;
                Zcon.g_WrongToken         += detailedDebug;

                puzzle.Default  = info.Default;
                puzzle.Solution = info.Solution;
                puzzle.Status   = Puzzle.PuzzleStatus.unsolved;

                puzzle.SetZcon(Zcon);

                Debug($"{puzzle.Name} with ID {puzzle.ID} successfully connected to the system");
            }
        }
Пример #2
0
        public static void Init()
        {
            LoadAllPuzzles();
            Server = new ConnectivityCore();
            GameItems.Server.g_NewErrorFromDevice += detailedDebug;
            Server.g_newDeviceConnected           += Server_newDeviceConnected;
            Server.g_newDebugMessage += Debug;

            BrainConnector.g_NewNetworkError += (sender, err) => {
                var p = GameItems.FindPuzzle((sender as BrainConnector).remoteID);
                Debug($"Network error at {p.Name} : {err.Message}");
            };
        }
Пример #3
0
        public static void detailedDebug(object sender, BrainMessage msg)
        {
            var p = GameItems.FindPuzzle((sender as BrainConnector).remoteID);

            Debug($"Error at {p.Name} : {msg.Params["Message"].ToString()}");
        }
Пример #4
0
        public static void detailedDebug(object sender, Exception err)
        {
            var p = GameItems.FindPuzzle((sender as BrainConnector).remoteID);

            Debug($"Error at {p.Name} : {err.Message}");
        }
Пример #5
0
 public static void Init()
 {
     GameItems.Init();
 }