diff --git a/libnpsharp.sln.DotSettings b/libnpsharp.sln.DotSettings index f94f86f..4a4f220 100644 --- a/libnpsharp.sln.DotSettings +++ b/libnpsharp.sln.DotSettings @@ -1,2 +1,3 @@  - NPID \ No newline at end of file + NPID + RPC \ No newline at end of file diff --git a/src/libnpsharp/NpClient.cs b/src/libnpsharp/NpClient.cs index d1dfa6a..c61698a 100644 --- a/src/libnpsharp/NpClient.cs +++ b/src/libnpsharp/NpClient.cs @@ -4,18 +4,18 @@ using System.IO; using System.Net; using System.Threading; using System.Threading.Tasks; -using NPSharp.Rpc; -using NPSharp.Rpc.Packets; using log4net; +using NPSharp.RPC; +using NPSharp.RPC.Packets; namespace NPSharp { /// /// Represents a high-level network platform client. /// - public class NpClient + public class NPClient { - private readonly RpcClientStream _rpc; + private readonly RPCClientStream _rpc; private CancellationTokenSource _cancellationTokenSource; private CancellationToken _cancellationToken; private ILog _log; @@ -25,9 +25,9 @@ namespace NPSharp /// /// The host to connect to. /// The port to use. Default: 3025. - public NpClient(string host, ushort port = 3025) + public NPClient(string host, ushort port = 3025) { - _rpc = new RpcClientStream(host, port); + _rpc = new RPCClientStream(host, port); _log = LogManager.GetLogger ("NPClient"); } diff --git a/src/libnpsharp/Rpc/Packets/AuthenticateExternalStatusMessage.cs b/src/libnpsharp/Rpc/Packets/AuthenticateExternalStatusMessage.cs index 9a1f875..78f2f56 100644 --- a/src/libnpsharp/Rpc/Packets/AuthenticateExternalStatusMessage.cs +++ b/src/libnpsharp/Rpc/Packets/AuthenticateExternalStatusMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1006)] [ProtoContract] - class AuthenticateExternalStatusMessage : RpcServerMessage + class AuthenticateExternalStatusMessage : RPCServerMessage { [ProtoMember(1)] public int Status { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/AuthenticateResultMessage.cs b/src/libnpsharp/Rpc/Packets/AuthenticateResultMessage.cs index f1ab79a..42cb81c 100644 --- a/src/libnpsharp/Rpc/Packets/AuthenticateResultMessage.cs +++ b/src/libnpsharp/Rpc/Packets/AuthenticateResultMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1010)] [ProtoContract] - class AuthenticateResultMessage : RpcServerMessage + class AuthenticateResultMessage : RPCServerMessage { [ProtoMember(1)] public int Result { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/AuthenticateWithTokenMessage.cs b/src/libnpsharp/Rpc/Packets/AuthenticateWithTokenMessage.cs index 1fa64cb..eff3199 100644 --- a/src/libnpsharp/Rpc/Packets/AuthenticateWithTokenMessage.cs +++ b/src/libnpsharp/Rpc/Packets/AuthenticateWithTokenMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1003)] [ProtoContract] - class AuthenticateWithTokenMessage : RpcClientMessage + class AuthenticateWithTokenMessage : RPCClientMessage { [ProtoMember(1)] public string Token { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/CloseAppMessage.cs b/src/libnpsharp/Rpc/Packets/CloseAppMessage.cs index abbc9c2..2dd2710 100644 --- a/src/libnpsharp/Rpc/Packets/CloseAppMessage.cs +++ b/src/libnpsharp/Rpc/Packets/CloseAppMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(2001)] [ProtoContract] - class CloseAppMessage : RpcServerMessage + class CloseAppMessage : RPCServerMessage { [ProtoMember(1)] public string Reason { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/HelloMessage.cs b/src/libnpsharp/Rpc/Packets/HelloMessage.cs index 741f805..42cb333 100644 --- a/src/libnpsharp/Rpc/Packets/HelloMessage.cs +++ b/src/libnpsharp/Rpc/Packets/HelloMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1000)] [ProtoContract] - class HelloMessage : RpcServerMessage + class HelloMessage : RPCServerMessage { // I seriously have no idea where in the code this is used but whatever [ProtoMember(1)] diff --git a/src/libnpsharp/Rpc/Packets/MessagingSendDataMessage.cs b/src/libnpsharp/Rpc/Packets/MessagingSendDataMessage.cs index 73e6b6e..360787c 100644 --- a/src/libnpsharp/Rpc/Packets/MessagingSendDataMessage.cs +++ b/src/libnpsharp/Rpc/Packets/MessagingSendDataMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(2002)] [ProtoContract] - class MessagingSendDataMessage : RpcClientMessage + class MessagingSendDataMessage : RPCClientMessage { [ProtoMember(1)] public ulong NPID { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/PacketAttribute.cs b/src/libnpsharp/Rpc/Packets/PacketAttribute.cs index 1dfe92b..ed5124b 100644 --- a/src/libnpsharp/Rpc/Packets/PacketAttribute.cs +++ b/src/libnpsharp/Rpc/Packets/PacketAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { class PacketAttribute : Attribute { diff --git a/src/libnpsharp/Rpc/Packets/RpcClientMessage.cs b/src/libnpsharp/Rpc/Packets/RpcClientMessage.cs index fdc85d9..d08ae6f 100644 --- a/src/libnpsharp/Rpc/Packets/RpcClientMessage.cs +++ b/src/libnpsharp/Rpc/Packets/RpcClientMessage.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.IO; using System.Net; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { - public class RpcClientMessage : RpcMessage + public class RPCClientMessage : RPCMessage { public byte[] Serialize(uint id) { diff --git a/src/libnpsharp/Rpc/Packets/RpcMessage.cs b/src/libnpsharp/Rpc/Packets/RpcMessage.cs index 020bf21..7712425 100644 --- a/src/libnpsharp/Rpc/Packets/RpcMessage.cs +++ b/src/libnpsharp/Rpc/Packets/RpcMessage.cs @@ -1,8 +1,8 @@ using System.Linq; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { - public class RpcMessage + public class RPCMessage { internal const uint Signature = 0xDEADC0DE; // I wonder if aiw3 changed this since kernal noted it in his source code. diff --git a/src/libnpsharp/Rpc/Packets/RpcServerMessage.cs b/src/libnpsharp/Rpc/Packets/RpcServerMessage.cs index e4adc8b..84de050 100644 --- a/src/libnpsharp/Rpc/Packets/RpcServerMessage.cs +++ b/src/libnpsharp/Rpc/Packets/RpcServerMessage.cs @@ -6,13 +6,13 @@ using System.Net; using System.Net.Sockets; using System.Reflection; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { - public class RpcServerMessage : RpcMessage + public class RPCServerMessage : RPCMessage { public uint MessageId { get; private set; } - public static RpcServerMessage Deserialize(NetworkStream ns) + public static RPCServerMessage Deserialize(NetworkStream ns) { var header = new byte[16]; var l = ns.Read(header, 0, header.Length); @@ -30,13 +30,13 @@ namespace NPSharp.Rpc.Packets if (signature != Signature) throw new ProtocolViolationException("Received packet with invalid signature"); - RpcServerMessage packet; + RPCServerMessage packet; using (var ms = new MemoryStream(buffer)) { var types = Assembly.GetExecutingAssembly().GetTypes().Where( t => - t.IsSubclassOf(typeof (RpcServerMessage)) + t.IsSubclassOf(typeof (RPCServerMessage)) && ((PacketAttribute) t.GetCustomAttributes(typeof (PacketAttribute), false).Single()).Type == type ).ToArray(); @@ -53,7 +53,7 @@ namespace NPSharp.Rpc.Packets return null; #endif } - packet = (RpcServerMessage)ProtoBuf.Serializer.NonGeneric.Deserialize( + packet = (RPCServerMessage)ProtoBuf.Serializer.NonGeneric.Deserialize( types.Single(), ms ); diff --git a/src/libnpsharp/Rpc/Packets/StorageGetPublisherFileMessage.cs b/src/libnpsharp/Rpc/Packets/StorageGetPublisherFileMessage.cs index 6f14f77..86b6732 100644 --- a/src/libnpsharp/Rpc/Packets/StorageGetPublisherFileMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StorageGetPublisherFileMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [ProtoContract] [Packet(1101)] - class StorageGetPublisherFileMessage : RpcClientMessage + class StorageGetPublisherFileMessage : RPCClientMessage { [ProtoMember(1)] public string FileName { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/StorageGetUserFileMessage.cs b/src/libnpsharp/Rpc/Packets/StorageGetUserFileMessage.cs index acda367..0b27e3b 100644 --- a/src/libnpsharp/Rpc/Packets/StorageGetUserFileMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StorageGetUserFileMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1102)] [ProtoContract] - class StorageGetUserFileMessage : RpcClientMessage + class StorageGetUserFileMessage : RPCClientMessage { [ProtoMember(1)] public string FileName { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/StoragePublisherFileMessage.cs b/src/libnpsharp/Rpc/Packets/StoragePublisherFileMessage.cs index c4c5c4c..77881b2 100644 --- a/src/libnpsharp/Rpc/Packets/StoragePublisherFileMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StoragePublisherFileMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1111)] [ProtoContract] - class StoragePublisherFileMessage : RpcServerMessage + class StoragePublisherFileMessage : RPCServerMessage { [ProtoMember(1)] public int Result { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/StorageSendRandomStringMessage.cs b/src/libnpsharp/Rpc/Packets/StorageSendRandomStringMessage.cs index 4ecd748..6943bf7 100644 --- a/src/libnpsharp/Rpc/Packets/StorageSendRandomStringMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StorageSendRandomStringMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1104)] [ProtoContract] - class StorageSendRandomStringMessage : RpcClientMessage + class StorageSendRandomStringMessage : RPCClientMessage { [ProtoMember(1)] public string RandomString { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/StorageUserFileMessage.cs b/src/libnpsharp/Rpc/Packets/StorageUserFileMessage.cs index cbb991b..3a2b85a 100644 --- a/src/libnpsharp/Rpc/Packets/StorageUserFileMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StorageUserFileMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1112)] [ProtoContract] - class StorageUserFileMessage : RpcServerMessage + class StorageUserFileMessage : RPCServerMessage { [ProtoMember(1)] public int Result { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/StorageWriteUserFileMessage.cs b/src/libnpsharp/Rpc/Packets/StorageWriteUserFileMessage.cs index f09472c..b9a9dd9 100644 --- a/src/libnpsharp/Rpc/Packets/StorageWriteUserFileMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StorageWriteUserFileMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1103)] [ProtoContract] - class StorageWriteUserFileMessage : RpcClientMessage + class StorageWriteUserFileMessage : RPCClientMessage { [ProtoMember(1)] public string FileName { get; set; } diff --git a/src/libnpsharp/Rpc/Packets/StorageWriteUserFileResultMessage.cs b/src/libnpsharp/Rpc/Packets/StorageWriteUserFileResultMessage.cs index 5bf17ca..8c7f463 100644 --- a/src/libnpsharp/Rpc/Packets/StorageWriteUserFileResultMessage.cs +++ b/src/libnpsharp/Rpc/Packets/StorageWriteUserFileResultMessage.cs @@ -1,10 +1,10 @@ using ProtoBuf; -namespace NPSharp.Rpc.Packets +namespace NPSharp.RPC.Packets { [Packet(1113)] [ProtoContract] - class StorageWriteUserFileResultMessage : RpcServerMessage + class StorageWriteUserFileResultMessage : RPCServerMessage { [ProtoMember(1)] public int Result { get; set; } diff --git a/src/libnpsharp/Rpc/RpcClientStream.cs b/src/libnpsharp/Rpc/RpcClientStream.cs index 918834e..c09522c 100644 --- a/src/libnpsharp/Rpc/RpcClientStream.cs +++ b/src/libnpsharp/Rpc/RpcClientStream.cs @@ -1,14 +1,14 @@ using System; using System.Collections.Generic; using System.Net.Sockets; -using NPSharp.Rpc.Packets; +using NPSharp.RPC.Packets; -namespace NPSharp.Rpc +namespace NPSharp.RPC { /// /// Represents a low-level client stream which can communicate with an NP server using RPC packets. /// - public class RpcClientStream + public class RPCClientStream { private NetworkStream _ns; private uint _id; @@ -16,14 +16,14 @@ namespace NPSharp.Rpc private readonly string _host; private readonly ushort _port; - private readonly Dictionary> _callbacks = new Dictionary>(); + private readonly Dictionary> _callbacks = new Dictionary>(); /// /// Initializes an RPC connection stream with a specified host and port. /// /// The host to connect to. /// The port to use. Default: 3025. - public RpcClientStream(string host, ushort port = 3025) + public RPCClientStream(string host, ushort port = 3025) { _host = host; _port = port; @@ -77,7 +77,7 @@ namespace NPSharp.Rpc /// Attaches a callback to the next message being sent out. This allows handling response packets. /// /// The method to call when we receive a response to the next message - public void AttachCallback(Action callback) + public void AttachCallback(Action callback) { if (_callbacks.ContainsKey(_id)) throw new Exception("There is already a callback for the current message. You can only add max. one callback."); @@ -90,7 +90,7 @@ namespace NPSharp.Rpc /// /// The RPC message to send out. /// The new ID of the message. - public uint Send(RpcClientMessage message) + public uint Send(RPCClientMessage message) { if (_ns == null) throw new InvalidOperationException("You need to open the stream first."); @@ -106,12 +106,12 @@ namespace NPSharp.Rpc /// Waits for the next RPC message from the server and reads it. /// /// The received server message. - public RpcServerMessage Read() + public RPCServerMessage Read() { if (_ns == null) throw new InvalidOperationException("You need to open the stream first."); - var message = RpcServerMessage.Deserialize(_ns); + var message = RPCServerMessage.Deserialize(_ns); if (message == null) return null; diff --git a/src/libnpsharp/libnpsharp.csproj b/src/libnpsharp/libnpsharp.csproj index c2b2f72..9490aa0 100644 --- a/src/libnpsharp/libnpsharp.csproj +++ b/src/libnpsharp/libnpsharp.csproj @@ -52,26 +52,26 @@ - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +