コード例 #1
0
            public bool Connect(int TimeOut = 10000)
            {
                try
                {
                    pipeStream.Connect(TimeOut);
                }
                catch
                {
                    return(false); // timeout
                }

                DataReceived += (sndr, data) =>
                {
                    RemoteCall call = ByteArrayToObject(data);

                    if (call.type == "push")
                    {
                        PushNotification?.Invoke(this, call);
                    }
                    else if (call.type == "call" && call.seqID == seqIDctr)
                    {
                        retObj = call;
                        done.Set();
                    }
                };

                PipeClosed += (sndr, args) => {
                    done.Set();
                };

                initAsyncReader();
                return(true);
            }
コード例 #2
0
ファイル: TournamentModule.cs プロジェクト: lobosjr/lobotjr
        private void System_TournamentEnded(TournamentResult result, DateTime?next)
        {
            string message;

            if (next == null)
            {
                message = "Stream has gone offline, so the fishing tournament was ended early. D:";
                if (result.Entries.Count > 0)
                {
                    message += $" Winner at the time of conclusion: {UserLookup.GetUsername(result.Winner.UserId)} with a score of {result.Winner.Points}.";
                }
            }
            else
            {
                if (result.Entries.Count > 0)
                {
                    message = $"The fishing tournament has ended! Out of {result.Entries.Count} participants, {UserLookup.GetUsername(result.Winner.UserId)} won with {result.Winner.Points} points!";
                }
                else
                {
                    message = "The fishing tournament has ended.";
                }
            }
            PushNotification?.Invoke(null, new CommandResult {
                Processed = true, Messages = new string[] { message }
            });
        }
コード例 #3
0
ファイル: TournamentModule.cs プロジェクト: lobosjr/lobotjr
        private void System_TournamentStarted(DateTime end)
        {
            var duration = end - DateTime.Now;
            var message  = $"A fishing tournament has just begun! For the next {Math.Round(duration.TotalMinutes)} minutes, fish can be caught more quickly & will be eligible for leaderboard recognition! Head to https://tinyurl.com/PlayWolfpackRPG and type !cast to play!";

            PushNotification?.Invoke(null, new CommandResult {
                Processed = true, Messages = new string[] { message }
            });
        }
コード例 #4
0
        private void FishingSystem_NewGlobalRecord(Catch catchData)
        {
            var recordMessage = $"{UserLookup.GetUsername(catchData.UserId)} just caught the heaviest {catchData.Fish.Name} ever! It weighs {catchData.Weight} pounds!";

            PushNotification?.Invoke(null, new CommandResult()
            {
                Messages = new string[] { recordMessage }
            });
        }
コード例 #5
0
ファイル: PipeClient.cs プロジェクト: safino9/priv10
            public bool Connect(int TimeOut = 10000)
            {
                try
                {
                    pipeStream.Connect(TimeOut);
                }
                catch
                {
                    return(false); // timeout
                }

                DataReceived += (sndr, data) =>
                {
                    EMessageTypes type  = EMessageTypes.eCall;
                    int           seqID = 0;
                    string        func  = null;
                    List <byte[]> args  = ParsePacket(data, ref type, ref seqID, ref func);

                    if (type == EMessageTypes.ePush)
                    {
                        PushNotification?.Invoke(this, new Tuple <string, List <byte[]> >(func, args));
                    }
                    else if (type == EMessageTypes.eCall)
                    {
                        if (seqID != seqIDctr)
                        {
                            Debug.Write("seqID != seqIDctr");
                        }
                        else
                        {
                            retObj = new Tuple <string, List <byte[]> >(func, args);
                            done.Set();
                        }
                    }
                };

                PipeClosed += (sndr, args) =>
                {
                    done.Set();
                };

                startRecv();
                return(true);
            }
コード例 #6
0
        public int BuyProduct(User user, Product product)
        {
            try
            {
                BuyTransaction buyTransaction = new BuyTransaction(user, product.Price);
                TrackTransaction(buyTransaction);
                Logger.WriteMessage(buyTransaction.ToString() + " Product Name & ID: " + product.Name + product.Id);
            }
            catch (InsufficientCreditsException e)
            {
                Logger.WriteMessage("ID:" + user.Id + " There were not enough credits on the user's account");
                return(1);
            }

            // Trigger event to notify user
            if (user.Money <= 2000)
            {
                PushNotification?.Invoke(this, new UserBalanceNotificationArgs(user.Money));
            }
            return(0);
        }
コード例 #7
0
 private void FishingSystem_FishGotAway(Fisher fisher)
 {
     PushNotification?.Invoke(fisher.UserId, new CommandResult("Heck! The fish got away. Maybe next time..."));
 }
コード例 #8
0
        private void FishingSystem_FishHooked(Fisher fisher)
        {
            var hookMessage = $"{fisher.Hooked.SizeCategory.Message} Type !catch to reel it in!";

            PushNotification?.Invoke(fisher.UserId, new CommandResult(hookMessage));
        }