diff --git a/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs b/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs index 5df2484..e7d97fa 100644 --- a/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs +++ b/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs @@ -6,6 +6,9 @@ using System; namespace AsterNET.IO { + /// + /// Socket connection to asterisk. + /// public class SocketConnection { private TcpClient tcpClient; @@ -23,21 +26,29 @@ namespace AsterNET.IO /// client port /// encoding public SocketConnection(string host, int port, Encoding encoding) + :this(new TcpClient(host, port), encoding) { - initial = true; - this.encoding = encoding; - this.tcpClient = new TcpClient(host, port); - this.networkStream = this.tcpClient.GetStream(); - this.reader = new StreamReader(this.networkStream, encoding); - this.writer = new BinaryWriter(this.networkStream, encoding); } + + /// + /// Consructor + /// + /// client host + /// client port + /// encoding + /// size of the receive buffer. + public SocketConnection(string host, int port,int receiveBufferSize, Encoding encoding) + : this (new TcpClient(host, port) {ReceiveBufferSize = receiveBufferSize }, encoding) + { + } + #endregion #region Constructor - SocketConnection(socket) /// /// Constructor /// - /// TCP client from Listener + /// TCP client from Listener /// encoding internal SocketConnection(TcpClient tcpClient, Encoding encoding) { diff --git a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs index f44421c..b14a5fa 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs @@ -653,14 +653,14 @@ namespace AsterNET.Manager /// the username to use for login /// the password to use for login /// text encoding to asterisk input/output stream - public ManagerConnection(string hostname, int port, string username, string password, Encoding encoding) + public ManagerConnection(string hostname, int port, string username, string password, Encoding socketEncoding) : this() { this.hostname = hostname; this.port = port; this.username = username; this.password = password; - this.socketEncoding = encoding; + this.socketEncoding = socketEncoding; } #endregion @@ -855,7 +855,8 @@ namespace AsterNET.Manager } #endregion - #region SocketEncoding + #region Socket Settings + /// /// Socket Encoding - default ASCII /// @@ -864,6 +865,12 @@ namespace AsterNET.Manager get { return socketEncoding; } set { socketEncoding = value; } } + + /// + /// Socket Receive Buffer Size + /// + public int SocketReceiveBufferSize { get; set;} + #endregion #region Version @@ -1075,7 +1082,10 @@ namespace AsterNET.Manager #endif try { - mrSocket = new SocketConnection(hostname, port, socketEncoding); + if (SocketReceiveBufferSize>0) + mrSocket = new SocketConnection(hostname, port, SocketReceiveBufferSize, socketEncoding); + else + mrSocket = new SocketConnection(hostname, port, socketEncoding); result = mrSocket.IsConnected; } #if LOGGER @@ -1083,8 +1093,8 @@ namespace AsterNET.Manager { logger.Info("Connect - Exception : {0}", ex.Message); #else - catch - { + catch + { #endif result = false; }