public void NewSession(Session session) { //session.IsListening = true; session.ErrorHandler = new FastServer.ServerErrorHandler(); session.MessageHandler = new MessageListener(); //register a template 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) }); ITemplateRegistry registry = new BasicTemplateRegistry {{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 override void OnError(Session session, DynError code, string message) { session.MessageOutputStream.WriteMessage(CreateFastAlertMessage(code)); }
public override void HandleMessage(Session session, Message message) { if (message.Template.Equals(AlertTemplate)) { var error = (DynError) message.GetInt(2); if (error == DynError.Close) { session.Close(error); } else { session.ErrorHandler.OnError(null, error, message.GetString(4)); } } }
public override Session Connect(string senderName, IConnection connection, ITemplateRegistry inboundRegistry, ITemplateRegistry outboundRegistry, IMessageListener messageListener, ISessionListener sessionListener) { var session = new Session(connection, this, TemplateRegistryFields.Null, TemplateRegistryFields.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 void OnMessage(Session session, Message message) { //Console.WriteLine("RCV TID:" + message.Template.Name);//UNCOMMENT }
public abstract void OnError(Session param1, DynError param2, string param3);
public abstract void HandleMessage(Session param1, Message param2);
public override void HandleMessage(Session session, Message message) { ISessionMessageHandler value; if (!MessageHandlers.TryGetValue(message.Template, out value)) return; value.HandleMessage(session, message); }
protected void SetUp() { _output = new StreamWriter(new MemoryStream()); _connection = new MyConnection(_output.BaseStream); _session = new Session(_connection, SessionConstants.Scp10, TemplateRegistryFields.Null, TemplateRegistryFields.Null); }
public void Connect() { _ses = _fc.Connect(); _ses.ErrorHandler = new ClientErrorHandler(); _ses.MessageHandler = new ClientMessageHandler(); }
public void HandleMessage(Session session, Message message) { MessageTemplate template = _enclosingInstance.CreateTemplateFromMessage( message, session.MessageInputStream.TemplateRegistry); session.AddDynamicTemplateDefinition(template); if (message.IsDefined("TemplateId")) session.RegisterDynamicTemplate(template.QName, message.GetInt("TemplateId")); }
public void HandleMessage(Session session, Message message) { session.RegisterDynamicTemplate(_enclosingInstance.GetQName(message), message.GetInt("TemplateId")); }
public void HandleMessage(Session session, Message message) { var alertCode = (DynError) message.GetInt(2); if (alertCode == DynError.Close) { session.Close(alertCode); } else { session.ErrorHandler.OnError(null, alertCode, message.GetString(4)); } }
public override Session OnNewConnection(string serverName, IConnection connection) { var session = new Session(connection, this, TemplateRegistryFields.Null, TemplateRegistryFields.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 abstract void ConfigureSession(Session param1);
public override void ConfigureSession(Session session) { RegisterSessionTemplates(session.MessageInputStream.TemplateRegistry); RegisterSessionTemplates(session.MessageOutputStream.TemplateRegistry); session.MessageInputStream.AddMessageHandler(FastResetTemplate, ResetHandler); session.MessageOutputStream.AddMessageHandler(FastResetTemplate, ResetHandler); }
public override Session Connect(string senderName, IConnection connection, ITemplateRegistry inboundRegistry, ITemplateRegistry outboundRegistry, IMessageListener messageListener, ISessionListener sessionListener) { var session = new Session(connection, this, TemplateRegistryFields.Null, TemplateRegistryFields.Null); session.MessageOutputStream.WriteMessage(CreateHelloMessage(senderName)); try { Thread.Sleep(new TimeSpan((Int64) 10000*20)); } catch (ThreadInterruptedException) { } Message 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; }