Welcome Guest Search | Active Topics | Members | Log In | Register

Vehicle tracking solution for xf.server? Options
foxley
Posted: Friday, October 23, 2009 12:24:53 AM
Rank: Member
Groups: Member

Joined: 9/22/2009
Posts: 4
Points: -85
Location: thai
i need to develop some software for vehicle tracking with XF.server for 64bit server

1. i need to know, i must to develop like a echo server or not, if i not need to send back message to blackbox.
2. i have 100 blackbox and setting interval of each blackbox @ 1 minute and i looking package size that sent to server not over 100 byte. pls recommend how to set a extened parameter.

Many thank every body.
admin
Posted: Friday, October 23, 2009 5:11:22 AM
Rank: Administration
Groups: Administration

Joined: 2/15/2008
Posts: 130
Points: 835
Hi,

1. Yes it will look much the same, you should create a listener and read data from the accepted client connections.
2. You may use default settings (don't specify extended parameter). Despite of the small package size you should implement correct package framing, because the package may be delivered fragmented. What protocol does a blackbox use?

In order to use XF.Network for commercial purpose on 64bit server you need to purchase a commercial license.
Please contact office@kodart.com for details.
foxley
Posted: Saturday, October 24, 2009 12:18:42 AM
Rank: Member
Groups: Member

Joined: 9/22/2009
Posts: 4
Points: -85
Location: thai
Many thank Admin
and if have some question.

when i develop version of
1.windows service(C#)
2.console applocation(c#)

windows service was not stable, Some imcomming can receive normally but not in some incomming. I must manual restart service the incomming will commig again.

console application can receive all incomming correctly.

i donn't know why?.
foxley
Posted: Saturday, October 24, 2009 12:26:02 AM
Rank: Member
Groups: Member

Joined: 9/22/2009
Posts: 4
Points: -85
Location: thai
Code for Windows service

static void Main()
{
using (IListener listener = Network.AcceptAsync(new IPEndPoint(IPAddress.Any, PORT_NUMBER), OnReadComplete))
{
System.ServiceProcess.ServiceBase[] ServicesToRun;

ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ServiceGatewayPool() };

System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
}

protected override void OnStart(string[] args)
{
eventLog.WriteEntry("Service is prepare start.");

ClassFileINI ini;

try {
ini = new ClassFileINI("C:\\xxx.ini");

............Read some parameter

Thread.Sleep(100);

queueMessage = new Queue(QUEUE_SIZE);

//========== Asyncronize process
timerQueue = new System.Timers.Timer();
timerQueue.Elapsed += new ElapsedEventHandler(OnQueueTimedEvent);
timerQueue.Interval = QUEUE_INTERVAL;
timerQueue.Enabled = true;
//==========

eventLog.WriteEntry("Service is start.");
}
catch {
eventLog.WriteEntry("Service is error on start queue.");
}
}

internal static void OnReadComplete(IConnection connection)
{
eventLog.WriteEntry("Incomming a message.");

connection.ReadAsync(
delegate(IConnection a, IMemoryBuffer buffer)
{
if (buffer != null)
{
/* acquire buffer to use it in asynchronous operation */
buffer.Acquire();

string message = Encoding.ASCII.GetString(buffer.Data).Substring(0, buffer.BytesTransfered);
string response = String.Format(responseFormat, message.Length, message);

/* send back received data */
connection.WriteAsync(buffer.Data, buffer.Offset, buffer.BytesTransfered,
delegate
{
buffer.Release();
}
);

message = message.Replace("\r", "").Replace("\n", "");

DoProcessQueue(message);

/* continue processing client requests */
OnReadComplete(connection);
}
else
{

}
}
);
}
foxley
Posted: Saturday, October 24, 2009 12:28:42 AM
Rank: Member
Groups: Member

Joined: 9/22/2009
Posts: 4
Points: -85
Location: thai
Code for Console application

static void Main()
{
using (IListener listener = Network.AcceptAsync(new IPEndPoint(IPAddress.Any, PORT_NUMBER), OnReadComplete))
{
queueMessage = new Queue(QUEUE_SIZE);

//==========
System.Timers.Timer timerQueue = new System.Timers.Timer();
timerQueue.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timerQueue.Interval = QUEUE_INTERVAL;
timerQueue.Enabled = true;
//==========

ConsoleKeyInfo cki;
Console.TreatControlCAsInput = false;
bool i = true;
while (i == true)
{
cki = Console.ReadKey(true);
if (cki.Key == ConsoleKey.X)
{
i = false;
Console.WriteLine("Engine was stop, Press any key to exit.");
Console.ReadKey(true);
}
}
}
}

internal static void OnReadComplete(IConnection connection)
{
Console.Write("Incomming message....");
Console.Write("\r\n");

connection.ReadAsync(
delegate(IConnection a, IMemoryBuffer buffer)
{
if (buffer != null)
{
/* acquire buffer to use it in asynchronous operation */
buffer.Acquire();

string message = Encoding.ASCII.GetString(buffer.Data).Substring(0, buffer.BytesTransfered);
string response = String.Format(responseFormat, message.Length, message);

/* send back received data */
connection.WriteAsync(buffer.Data, buffer.Offset, buffer.BytesTransfered,
delegate
{
buffer.Release();
}
);

message = message.Replace("\r", "").Replace("\n", "");

DoProcessQueue(message);

/* continue processing client requests */
OnReadComplete(connection);
}
}
);
}


PLEASE ADVISE ME.
admin
Posted: Saturday, October 24, 2009 4:32:25 AM
Rank: Administration
Groups: Administration

Joined: 2/15/2008
Posts: 130
Points: 835
Hi,

In service implementation I would suggest you to create a listener in OnStart and dispose it in OnStop.
Another point is that you use an older version of the component, please download a new release.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.6 (NET v2.0) - 11/14/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.120 seconds.
13 queries (0.032 seconds, 26.67%).

yaf_pageload: 0.006
yaf_topic_info: 0.001
yaf_forum_list: 0.001
yaf_forum_listpath: 0.001
yaf_forum_listpath: 0.001
yaf_post_list: 0.013
yaf_usergroup_list: 0.001
yaf_usergroup_list: 0.001
yaf_usergroup_list: 0.001
yaf_usergroup_list: 0.002
yaf_usergroup_list: 0.001
yaf_usergroup_list: 0.001
yaf_active_listtopic: 0.002