Capitalization.

feature-npv2
Icedream 2014-05-07 17:33:31 +02:00
parent a0c75f4122
commit 0d0a3b76fe
21 changed files with 73 additions and 72 deletions

View File

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NPID/@EntryIndexedValue">NPID</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NPID/@EntryIndexedValue">NPID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RPC/@EntryIndexedValue">RPC</s:String></wpf:ResourceDictionary>

View File

@ -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
{
/// <summary>
/// Represents a high-level network platform client.
/// </summary>
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
/// </summary>
/// <param name="host">The host to connect to.</param>
/// <param name="port">The port to use. Default: 3025.</param>
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");
}

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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)]

View File

@ -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; }

View File

@ -1,6 +1,6 @@
using System;
namespace NPSharp.Rpc.Packets
namespace NPSharp.RPC.Packets
{
class PacketAttribute : Attribute
{

View File

@ -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)
{

View File

@ -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.

View File

@ -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
);

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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
{
/// <summary>
/// Represents a low-level client stream which can communicate with an NP server using RPC packets.
/// </summary>
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<uint, Action<RpcServerMessage>> _callbacks = new Dictionary<uint, Action<RpcServerMessage>>();
private readonly Dictionary<uint, Action<RPCServerMessage>> _callbacks = new Dictionary<uint, Action<RPCServerMessage>>();
/// <summary>
/// Initializes an RPC connection stream with a specified host and port.
/// </summary>
/// <param name="host">The host to connect to.</param>
/// <param name="port">The port to use. Default: 3025.</param>
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.
/// </summary>
/// <param name="callback">The method to call when we receive a response to the next message</param>
public void AttachCallback(Action<RpcServerMessage> callback)
public void AttachCallback(Action<RPCServerMessage> 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
/// </summary>
/// <param name="message">The RPC message to send out.</param>
/// <returns>The new ID of the message.</returns>
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.
/// </summary>
/// <returns>The received server message.</returns>
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;

View File

@ -52,26 +52,26 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="NpClient.cs" />
<Compile Include="NPClient.cs" />
<Compile Include="NPFileException.cs" />
<Compile Include="Rpc\RpcClientStream.cs" />
<Compile Include="Rpc\Packets\AuthenticateExternalStatusMessage.cs" />
<Compile Include="Rpc\Packets\AuthenticateResultMessage.cs" />
<Compile Include="Rpc\Packets\AuthenticateWithTokenMessage.cs" />
<Compile Include="Rpc\Packets\CloseAppMessage.cs" />
<Compile Include="Rpc\Packets\HelloMessage.cs" />
<Compile Include="Rpc\Packets\MessagingSendDataMessage.cs" />
<Compile Include="Rpc\Packets\RpcMessage.cs" />
<Compile Include="Rpc\Packets\PacketAttribute.cs" />
<Compile Include="Rpc\Packets\RpcClientMessage.cs" />
<Compile Include="Rpc\Packets\RpcServerMessage.cs" />
<Compile Include="Rpc\Packets\StorageGetUserFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageGetPublisherFileMessage.cs" />
<Compile Include="Rpc\Packets\StoragePublisherFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageSendRandomStringMessage.cs" />
<Compile Include="Rpc\Packets\StorageUserFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageWriteUserFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageWriteUserFileResultMessage.cs" />
<Compile Include="RPC\RPCClientStream.cs" />
<Compile Include="RPC\Packets\AuthenticateExternalStatusMessage.cs" />
<Compile Include="RPC\Packets\AuthenticateResultMessage.cs" />
<Compile Include="RPC\Packets\AuthenticateWithTokenMessage.cs" />
<Compile Include="RPC\Packets\CloseAppMessage.cs" />
<Compile Include="RPC\Packets\HelloMessage.cs" />
<Compile Include="RPC\Packets\MessagingSendDataMessage.cs" />
<Compile Include="RPC\Packets\RPCMessage.cs" />
<Compile Include="RPC\Packets\PacketAttribute.cs" />
<Compile Include="RPC\Packets\RPCClientMessage.cs" />
<Compile Include="RPC\Packets\RPCServerMessage.cs" />
<Compile Include="RPC\Packets\StorageGetUserFileMessage.cs" />
<Compile Include="RPC\Packets\StorageGetPublisherFileMessage.cs" />
<Compile Include="RPC\Packets\StoragePublisherFileMessage.cs" />
<Compile Include="RPC\Packets\StorageSendRandomStringMessage.cs" />
<Compile Include="RPC\Packets\StorageUserFileMessage.cs" />
<Compile Include="RPC\Packets\StorageWriteUserFileMessage.cs" />
<Compile Include="RPC\Packets\StorageWriteUserFileResultMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Authentication\AuthenticationHelper.cs" />
</ItemGroup>