using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Protocol;
using SuperSocket.SocketBase.Config;
using System.Net;
namespace SuperSocket.SocketEngine
{
///
/// Default socket server factory
///
public class SocketServerFactory : ISocketServerFactory
{
#region ISocketServerFactory Members
///
/// Creates the socket server.
///
/// The type of the request info.
/// The app server.
/// The listeners.
/// The config.
///
public ISocketServer CreateSocketServer(IAppServer appServer, ListenerInfo[] listeners, IServerConfig config)
where TRequestInfo : IRequestInfo
{
if (appServer == null)
throw new ArgumentNullException("appServer");
if (listeners == null)
throw new ArgumentNullException("listeners");
if (config == null)
throw new ArgumentNullException("config");
switch(config.Mode)
{
case(SocketMode.Tcp):
return new AsyncSocketServer(appServer, listeners);
case(SocketMode.Udp):
return new UdpSocketServer(appServer, listeners);
default:
throw new NotSupportedException("Unsupported SocketMode:" + config.Mode);
}
}
#endregion
}
}