public void NewSession(Session session)
        {
            //session.Listening = true;
            session.ErrorHandler = new TCPServer.FASTServer.ServerErrorHandler();
            session.MessageHandler = new FASTMessageListener();
            //register a template
            TemplateRegistry registry = new BasicTemplateRegistry();
            var template = new MessageTemplate("Arbitry",
               new Field[] {
                    new Scalar("1", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.I32, Operator.DELTA, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.I32, Operator.INCREMENT,
                        new IntegerValue(10), false),
                    new Scalar("4", FASTType.I32, Operator.INCREMENT,
                        ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.I32, Operator.CONSTANT,
                        new IntegerValue(1), false), /* NON-TRANSFERRABLE */
                new Scalar("6", FASTType.I32, Operator.DEFAULT,
                        new IntegerValue(2), false)
                });
            registry.Register(24, template);

            session.MessageInputStream.RegisterTemplate(24, template);
            //send that template
            session.SendTemplates(registry);

            while (true)
            {
                DateTime startTime = DateTime.Now;
                for (int i = 0; i < 64000; i++)
                {
                    //make a message
                    var message = new Message(template);
                    message.SetInteger(1, 109);
                    message.SetInteger(2, 29470);
                    message.SetInteger(3, 10);
                    message.SetInteger(4, 3);
                    message.SetInteger(5, 1);
                    message.SetInteger(6, 2);

                    //send it to client
                    session.MessageOutputStream.WriteMessage(message);
                }
                double seconds = (DateTime.Now - startTime).TotalSeconds;
                Console.WriteLine(seconds);
                Console.WriteLine("MSG/S:" + (64000 / seconds).ToString("0"));
            }
        }
 public abstract void HandleMessage(Session param1, Message param2);
 public abstract void ConfigureSession(Session param1);
Beispiel #4
0
 private void InitBlock(Session internalInstance)
 {
     enclosingInstance = internalInstance;
 }
Beispiel #5
0
 public SessionThread(Session enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
 public override Session OnNewConnection(string serverName, Connection connection)
 {
     var session = new Session(connection, this, TemplateRegistry_Fields.NULL, TemplateRegistry_Fields.NULL);
     Message message = session.MessageInputStream.ReadMessage();
     session.MessageOutputStream.WriteMessage(CreateHelloMessage(serverName));
     string clientName = message.GetString(1);
     session.Client = new BasicClient(clientName, "unknown");
     return session;
 }
 public override Session Connect(string senderName, Connection connection, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry, MessageListener messageListener, SessionListener sessionListener)
 {
     var session = new Session(connection, this, TemplateRegistry_Fields.NULL, TemplateRegistry_Fields.NULL);
     session.MessageOutputStream.WriteMessage(CreateHelloMessage(senderName));
     try
     {
         System.Threading.Thread.Sleep(new TimeSpan((Int64) 10000 * 20));
     }
     catch (System.Threading.ThreadInterruptedException)
     {
     }
     var message = session.MessageInputStream.ReadMessage();
     string serverName = message.GetString(1);
     string vendorId = message.IsDefined(2)?message.GetString(2):"unknown";
     session.Client = new BasicClient(serverName, vendorId);
     return session;
 }
 //When the server sends a message this will print that on the console.
 public void OnMessage(Session session, Message message)
 {
     //Console.WriteLine("RCV TID:" + message.Template.Name);//UNCOMMENT
 }
 public override Session Connect(string senderName, Connection connection, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry, MessageListener messageListener, SessionListener sessionListener)
 {
     var session = new Session(connection, this, TemplateRegistry_Fields.NULL, TemplateRegistry_Fields.NULL);
     session.MessageOutputStream.WriteMessage(CreateHelloMessage(senderName));
     Message message = session.MessageInputStream.ReadMessage();
     string serverName = message.GetString(1);
     session.Client = new BasicClient(serverName, "unknown");
     return session;
 }
 public override void ConfigureSession(Session session)
 {
     RegisterSessionTemplates(session.MessageInputStream.GetTemplateRegistry());
     RegisterSessionTemplates(session.MessageOutputStream.GetTemplateRegistry());
     session.MessageInputStream.AddMessageHandler(FAST_RESET_TEMPLATE, RESET_HANDLER);
     session.MessageOutputStream.AddMessageHandler(FAST_RESET_TEMPLATE, RESET_HANDLER);
 }
 public virtual void HandleMessage(Session session, Message message)
 {
     var template = Enclosing_Instance.CreateTemplateFromMessage(message, session.MessageInputStream.GetTemplateRegistry());
     session.AddDynamicTemplateDefinition(template);
     if (message.IsDefined("TemplateId"))
         session.RegisterDynamicTemplate(template.QName, message.GetInt("TemplateId"));
 }
 public virtual void HandleMessage(Session session, Message message)
 {
     session.RegisterDynamicTemplate(Enclosing_Instance.GetQName(message), message.GetInt("TemplateId"));
 }
 public virtual void HandleMessage(Session session, Message message)
 {
     ErrorCode alertCode = ErrorCode.GetAlertCode(message);
     if (alertCode.Equals(SessionConstants.CLOSE))
     {
         session.Close(alertCode);
     }
     else
     {
         session.ErrorHandler.Error(alertCode, message.GetString(4));
     }
 }
 public override void HandleMessage(Session session, Message message)
 {
     if (!messageHandlers.Contains(message.Template))
         return ;
     ((SessionMessageHandler) messageHandlers[message.Template]).HandleMessage(session, message);
 }
 public abstract void OnError(Session param1, Error.ErrorCode param2, string param3);
 public override void HandleMessage(Session session, Message message)
 {
     if (message.Template.Equals(FAST_ALERT_TEMPLATE))
     {
         ErrorCode alertCode = ErrorCode.GetAlertCode(message);
         if (alertCode.Equals(SessionConstants.CLOSE))
         {
             session.Close(alertCode);
         }
         else
         {
             session.ErrorHandler.Error(alertCode, message.GetString(4));
         }
     }
 }
 public override void OnError(Session session, ErrorCode code, string message)
 {
     session.MessageOutputStream.WriteMessage(CreateFastAlertMessage(code));
 }
 public void Connect()
 {
     ses = fc.Connect();
     ses.ErrorHandler = new ClientErrorHandler();
     ses.MessageHandler = new FASTClientMessageHandler();
 }
 protected void setUp()
 {
     output = new StreamWriter(new MemoryStream());
     session = new Session(new MyConnection(output.BaseStream), SessionConstants.SCP_1_0, TemplateRegistry_Fields.NULL, TemplateRegistry_Fields.NULL);
 }