61 lines
2.1 KiB
C#
61 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace BCG {
|
|
public delegate void SendConfirmationDelegate(string messageId, bool confirmed);
|
|
/// <summary>
|
|
/// This is the very basic connection that sits right
|
|
/// on top of the sockets (used on both server and client)
|
|
/// </summary>
|
|
public interface ITCPConnection : IDisposable {
|
|
public enum ConnectionSide {
|
|
Client,
|
|
Server
|
|
}
|
|
/// <summary>
|
|
/// The delegate is fired signalling if the data send was
|
|
/// successful or not
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <param name="confId"></param>
|
|
/// <param name="del"></param>
|
|
void sendWithConfirmation(byte[] data, ref string confId, SendConfirmationDelegate del);
|
|
/// <summary>
|
|
/// sends data to the other side. theres no guaranatee that
|
|
/// data is delievered.
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
void send(byte[] data);
|
|
/// <summary>
|
|
/// registers a ITCPMessageHandler, to receive messages
|
|
/// from the other side.
|
|
/// </summary>
|
|
/// <param name="messageHandler"></param>
|
|
void register(ITCPMessageHandler messageHandler);
|
|
|
|
/// <summary>
|
|
/// Gets the ip and port of the peer to which this
|
|
/// connection is connected.
|
|
/// </summary>
|
|
/// <param name="ip"></param>
|
|
/// <param name="port"></param>
|
|
void getPeerAddress(out string ip, out int port);
|
|
|
|
/// <summary>
|
|
/// Gets its own ip and port, as seen by the peer. So if this
|
|
/// is the client, it will returns its ip and the port, as the
|
|
/// server sees it. For server, this is the ip and wellknown
|
|
/// port of the server
|
|
/// </summary>
|
|
/// <param name="ip"></param>
|
|
/// <param name="port"></param>
|
|
void getSelfAddress(out string ip, out int port);
|
|
/// <summary>
|
|
/// if the connection is disconnected, it disposes itself,
|
|
/// hence this is an indicator of whether the connection is
|
|
/// alive or dead
|
|
/// </summary>
|
|
bool isDisposed { get; }
|
|
}
|
|
} |