public FSharpAsync <ConnectionAction> OnConnectionBeforeHandler(
            IDiResolveReleaseOnlyContainer di, string url, object serviceInstanceOrNull,
            MethodInfo methodOrNull, object[] parms, ResourceType res)
        {
            var ci   = di.Resolve <ClientConnectionInfo>();
            var guid = Guid.NewGuid().ToString();

            LogAsReply($"OnConnectionBeforeHandler() ip={ci.ClientIpAddress} guid={guid} url={url} resourceType={res.ToString()} serviceImpl={serviceInstanceOrNull} method={methodOrNull} parms={parms}");

            var ctx = new FilterInvocation {
                Url     = url,
                ResType = res,
                InvType = FilterInvocationType.BeforeConnection,
                FullInterfaceNameOrNull = serviceInstanceOrNull == null ?
                                          null
                    :
                                          FindServiceInterfaceType(serviceInstanceOrNull).FullName,
                MethodNameOrNull = methodOrNull?.Name,
                Guid             = guid
            };

            SendFilterInvocation(ctx);

            return(FSharpAsyncUtil.FromResult(ConnectionAction.CreateNonFiltered(ctx)));
        }
Пример #2
0
 void CheckMouseEvent(Event e)
 {
     //start a connection action
     if (e.button == 0 && e.type == EventType.MouseDown)
     {
         //add connection
         if (e.shift)
         {
             action        = ConnectionAction.Add;
             currentSearch = SearchReason.Start;
             e.Use();
         }
         //remove connection
         else if (e.control)
         {
             action        = ConnectionAction.Delete;
             currentSearch = SearchReason.Start;
             e.Use();
         }
     }
     else if (e.button == 0 && e.type == EventType.MouseDrag)
     {
         currentSearch = SearchReason.End;
         e.Use();
     }
 }
Пример #3
0
        private void ReassessOwnership(SyncService deltaUser, ConnectionAction action)
        {
            var oldOwner = Owner;

            // base case if only one user remains online
            if (ActiveUsers == 1)
            {
                Owner = Services.First();
            }
            else if (action == ConnectionAction.CLOSED && deltaUser.ID == Owner.ID && ActiveUsers > 0)
            {
                // set the owner to the last joined user if current owner left
                Owner = Services.First();
            }
            else if (ActiveUsers == 0)
            {
                Logger.Log("Room {0} has no owner, will be destroyed in 1 minute.", RoomCode);
                Owner = null;
            }

            if (Owner != null && Owner.Permissions != UserPermissionLevel.OWNER)
            {
                Owner.Permissions = UserPermissionLevel.OWNER;
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ConnectionAction connectionAction = db.ConnectionActions.Find(id);

            db.ConnectionActions.Remove(connectionAction);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private static ConnectionAction ParseHttpCodeAndResponse(string httpLine, string response, ShoutcastStream shoutStream)
        {
            var bits = httpLine.Split(new char[] { ' ' }, 3);

            var protocolBit = bits[0].ToUpper(); //always 'HTTP' or 'ICY
            int statusCode  = int.Parse(bits[1]);

            string[] responseSplitByLine            = response.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            KeyValuePair <string, string>[] headers = ParseHttpResponseToKeyPairArray(responseSplitByLine);

            switch (protocolBit)
            {
            case "ICY":
            {
                switch (statusCode)
                {
                case 200: return(ConnectionAction.FromSuccess());
                }
            }
            break;

            default:
                if (protocolBit.StartsWith("HTTP/"))
                {
                    switch (statusCode)
                    {
                    case 200: return(ConnectionAction.FromSuccess());

                    case 400:         //bad request
                    case 404: return(ConnectionAction.FromFailure());

                    case 503:         //server limit reached
                        return(ConnectionAction.FromFailure(new Exception("Server limit reached.")));

                    case 302:         //Found. Has the new location in the LOCATION header.
                    {
                        var newLocation = headers.FirstOrDefault(x => x.Key.ToUpper().Equals("LOCATION"));
                        if (!string.IsNullOrWhiteSpace(newLocation.Value))
                        {
                            //We need to connect to this url instead. Throw it back to the top.
                            return(new ConnectionAction()
                                {
                                    ActionType = ConnectionActionType.Redirect,
                                    ActionUrl = new Uri(newLocation.Value)
                                });
                        }
                        else
                        {
                            return(ConnectionAction.FromFailure());
                        }
                    }
                    }
                }
                break;
            }

            return(null);
        }
Пример #6
0
        public void Run(ConnectionAction action)
        {
            tcpClient.Connect(IP, PORT);
            Console.WriteLine("Connected to server!");

            WaitForOKSignal();

            action.Invoke(_socket);
        }
Пример #7
0
        private void Service_ConnectionOpenedOrClosed(ConnectionAction action, SyncService s)
        {
            if (action == ConnectionAction.OPENED)
            {
                Logger.Log("Client [{0}] connected. {1} clients online in room {2}.", s.Nickname, Services.Count, RoomCode);

                if (CurrentQueue.URLs != null)
                {
                    // update new user with queue
                    var res = new
                    {
                        CommandType = CommandType.QUEUEUPDATE.Value,
                        Queue       = new
                        {
                            Name       = CurrentQueue.Name,
                            QueueIndex = CurrentQueue.QueueIndex,
                            URLs       = CurrentQueue.URLs
                        }
                    };

                    s.SendMessage(JsonConvert.SerializeObject(res));
                }


                // notify service of their nickname
                var res1 = new
                {
                    CommandType = CommandType.SETUSERNICKNAME.Value,
                    Nickname    = s.Nickname
                };

                s.SendMessage(JsonConvert.SerializeObject(res1));


                // notify service of like count
                var res2 = new
                {
                    CommandType = CommandType.UPDATELIKES.Value,
                    Likes       = likes
                };

                s.SendMessage(JsonConvert.SerializeObject(res2));
            }
            else
            {
                int index = Services.FindIndex(x => x.ID == s.ID);
                Services.RemoveAt(index);
                Logger.Log("Client [{0}] disconnected. {1} clients online in room {2}.", s.Nickname, Services.Count, RoomCode);
            }


            ActiveUsers = Services.Count;
            ReassessOwnership(s, action);

            SendUserList();
        }
Пример #8
0
        public FSharpAsync <ConnectionAction> OnConnectionBeforeHandler(
            IDiResolveReleaseOnlyContainer di, string url, object serviceInstance,
            MethodInfo method, object[] prms, ResourceType res)
        {
            var ci   = di.Resolve <ClientConnectionInfo>();
            var guid = Guid.NewGuid().ToString();

            Logger.Debug(typeof(LifeTimeFilter), $"OnConnectionBeforeHandler() ip={ci.ClientIpAddress} guid={guid} url={url} resourceType={res.ToString()} serviceImpl={serviceInstance} method={method} prms={prms}");
            return(FSharpAsyncUtil.FromResult(ConnectionAction.CreateNonFiltered(guid)));
        }
 public ActionResult Edit([Bind(Include = "ConnectionActionId,ConnectionActionDescription,PointsEarned,ConnectionActionDate,FamilyMemberId")] ConnectionAction connectionAction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(connectionAction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FamilyMemberId = new SelectList(db.FamilyMembers, "FamilyMemberId", "FirstName", connectionAction.FamilyMemberId);
     return(View(connectionAction));
 }
        public ActionResult Create([Bind(Include = "ConnectionActionId,ConnectionActionDescription,PointsEarned,ConnectionActionDate,FamilyMemberId,UserId")] ConnectionAction connectionAction)
        {
            if (ModelState.IsValid)
            {
                connectionAction.UserId = User.Identity.GetUserId();
                db.ConnectionActions.Add(connectionAction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FamilyMemberId = new SelectList(db.FamilyMembers, "FamilyMemberId", "FirstName", connectionAction.FamilyMemberId);
            return(View(connectionAction));
        }
Пример #11
0
    void CheckForActionChange(Event e)
    {
        //check if user action has changed

        if (e.type == EventType.KeyDown && (e.keyCode == KeyCode.LeftShift || e.keyCode == KeyCode.RightShift))
        {
            action = ConnectionAction.Add;
        }
        else if (e.type == EventType.KeyDown && (e.keyCode == KeyCode.LeftControl || e.keyCode == KeyCode.RightControl))
        {
            action = ConnectionAction.Delete;
        }
    }
        // GET: ConnectionActions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ConnectionAction connectionAction = db.ConnectionActions.Find(id);

            if (connectionAction == null)
            {
                return(HttpNotFound());
            }
            return(View(connectionAction));
        }
        // GET: ConnectionActions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ConnectionAction connectionAction = db.ConnectionActions.Find(id);

            if (connectionAction == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FamilyMemberId = new SelectList(db.FamilyMembers, "FamilyMemberId", "FirstName", connectionAction.FamilyMemberId);
            return(View(connectionAction));
        }
Пример #14
0
        public void ConnectToServer(IPEndPoint serverEndPoint)
        {
            Debug.Log("Connecting to server.");
            int          serverId         = _networkManager.AddConnection(serverEndPoint);
            EventAction  connectionAction = new ConnectionAction();
            EventBuilder eventBuilder     = _networkManager.AddNetworkInfo(new EventBuilder(), serverId);
            Event        connectionEvent  = eventBuilder.SetAck(false)
                                            .SetClientId(serverId)
                                            .SetTimeoutType(connectionAction.GetTimeoutType())
                                            .SetEventType(connectionAction.GetEventType())
                                            .SetPayload(connectionAction)
                                            .Build();

            _networkManager.SendEventFakingLatencyAndPacketLoss(connectionEvent);

            AddEventToReliableQueue(connectionEvent);
        }
Пример #15
0
 public override void Connected()
 {
     ConnectionAction?.Invoke();
 }
Пример #16
0
 public void DeserializeFrom(Stream stream)
 {
     var br = new BinaryReader(stream);
     Action = (ConnectionAction) br.ReadByte();
 }
Пример #17
0
 public ConnectionManagementPacket(ConnectionAction action)
 {
     Action = action;
 }
        //Xem entity này có phải entity ở db lịch sử hay không?
        public static bool IsHistory(string entityName)
        {
            #region Daily
            if (entityName.Equals(AccountDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(AccountInfoDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(BaseSymbolDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ForexRateDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(MemberLimitDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OpenPositionDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OpenPositionDetailDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OrderTransactionDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(SymbolSettlementPriceDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ForexRateInternalDaily.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ImLmeDaily.EntityName()))
            {
                return(true);
            }

            #endregion

            #region Hist
            if (entityName.Equals(AlertEmailHis.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(AlertSmsHis.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(LinkedTransactionHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OpenPositionDetailHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OpenPositionHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OrderTransactionHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(TradingDealHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(AccountTransactionHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(SpecAccountingHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ExecutionReportHist.EntityName()))
            {
                return(true);
            }

            if (entityName.Equals(ApprovalAccountHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ApprovalDealingHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ApprovalMemberHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ApprovalOrderHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ApprovalPreRiskHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ApprovalSystemHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(SessionHistoryMove.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ContractNoticeDateHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(BrokerOrderHist.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(SystemMessage.EntityName()))
            {
                return(true);
            }
            #endregion

            #region Action
            if (entityName.Equals(SymbolSettlementPriceAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(TradingDealAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(SystemConfigAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(SymbolCQGAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(OrderTransactionAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ManualPriceAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ForexRateAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(BaseSymbolCQGAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(BaseSymbolAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ConnectionAction.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(ForexRateInternalAction.EntityName()))
            {
                return(true);
            }
            #endregion

            //Các bảng khác
            if (entityName.Equals(ActionLog.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(StateChangedAccount.EntityName()))
            {
                return(true);
            }
            if (entityName.Equals(YdspLme.EntityName()))
            {
                return(true);
            }

            return(false);
        }
 public ConnectionManagementPacket(ConnectionAction action)
 {
     Action = action;
 }
        public void DeserializeFrom(Stream stream)
        {
            var br = new BinaryReader(stream);

            Action = (ConnectionAction)br.ReadByte();
        }
Пример #21
0
 public void Connected()
 {
     ConnectionAction?.Invoke();
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the ConnectionChangingEventArgs class.
 /// </summary>
 /// <param name="action"></param>
 /// <param name="inputPort"></param>
 public ConnectionChangedEventArgs(ConnectionAction action)
 {
     Action = action;
 }