Skip to content
Permalink
Browse files

web

  • Loading branch information...
Splamy committed Oct 7, 2019
1 parent f887574 commit 7a2434ab1f00118a5dd1655343f8fcaca0e6adb7
@@ -239,7 +239,7 @@ public int Read(byte[] buffer, int offset, int length, out Meta meta)
};
newInstance.OnMetaUpdated = e => OnSongUpdated(this, e);

new Thread(newInstance.ReadStreamLoop)
new Thread(() => newInstance.ReadStreamLoop(id))
{
Name = $"IcyStreamReader[{id}]",
}.Start();
@@ -391,8 +391,9 @@ public void FfmpegProcess_ErrorDataReceived(object sender, DataReceivedEventArgs
//}
}

public void ReadStreamLoop()
public void ReadStreamLoop(Id id)
{
Util.SetLogId(id.ToString());
const int IcyMaxMeta = 255 * 16;
const int ReadBufferSize = 4096;

@@ -150,7 +150,12 @@ public static R<T> TryCast<T>(this JToken token, string key)
var value = token.SelectToken(key);
if (value is null)
return R.Err;
try { return value.ToObject<T>(); }
try {
var t = value.ToObject<T>();
if ((object)t is null)
return R.Err;
return t;
}
catch (JsonReaderException) { return R.Err; }
}

@@ -889,7 +889,7 @@ public static JsonValue<PlaylistInfo> CommandListImport(PlaylistManager playlist
return CommandListShow(playlistManager, resourceFactory, listId, null, null);
}

[Command("list insert")]
[Command("list insert", "_undocumented")] // TODO Doc
public static JsonValue<PlaylistItemGetData> CommandListAddInternal(ResourceFactory resourceFactory, InvokerData invoker, PlaylistManager playlistManager, string listId, int index, string link /* TODO param */)
{
PlaylistItemGetData getData = null;
@@ -1247,11 +1247,11 @@ private static AudioResource GetSearchResult(this UserSession session, int index
return result.Value[index];
}

[Command("search add")]
[Command("search add", "_undocumented")] // TODO Doc
public static void CommandSelect(PlayManager playManager, InvokerData invoker, UserSession session, int index)
=> playManager.Enqueue(invoker, session.GetSearchResult(index)).UnwrapThrow();

[Command("search play")]
[Command("search play", "_undocumented")] // TODO Doc
public static void CommandSelect(PlayManager playManager, ClientCall clientCall, UserSession session, int index)
=> playManager.Play(clientCall, session.GetSearchResult(index)).UnwrapThrow();

@@ -374,8 +374,8 @@ public JsonArray<AudioResource> PropagiateSearch(UserSession session, CallerInfo
var tmb = new TextModBuilder(callerInfo.IsColor);
tmb.AppendFormat(
strings.cmd_search_header.Mod().Bold(),
("!select " + strings.info_number).Mod().Italic(),
("!queue " + strings.info_number).Mod().Italic()).Append("\n");
("!search play " + strings.info_number).Mod().Italic(),
("!search add " + strings.info_number).Mod().Italic()).Append("\n");
for (int i = 0; i < searchResults.Count; i++)
{
tmb.AppendFormat("{0}: {1}\n", i.ToString().Mod().Bold(), searchResults[i].ResourceTitle);
@@ -39,6 +39,7 @@
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="LiteDB" Version="4.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.3.1">
@@ -111,8 +111,21 @@ private void StartWebServerInternal()
{
kestrel.Limits.MaxRequestBodySize = 3_000_000; // 3 MiB should be enough
})
.ConfigureServices(services =>
{
services.AddCors(options =>
{
options.AddPolicy("TS3AB", builder =>
{
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
});
});

})
.Configure(app =>
{
app.UseCors("TS3AB");

app.Map(new PathString("/api"), map =>
{
map.Run(ctx => Task.Run(() => Log.Swallow(() => api.ProcessApiV1Call(ctx))));
@@ -141,7 +141,7 @@ public E<CommandError> Resume(FileTransferToken token)
return result.Error;
var request = result.Value;
token.ServerTransferId = request.ServerFileTransferId;
token.SeekPosition = request.SeekPosistion;
token.SeekPosition = (long)request.SeekPosition;
token.Port = request.Port;
token.TransferKey = request.FileTransferKey;
}
@@ -311,13 +311,13 @@ public sealed class FileTransferToken
public FileTransferToken(Stream localStream, FileUpload upload, ChannelIdT channelId,
string path, string channelPassword, long size, bool createMd5)
: this(localStream, upload.ClientFileTransferId, upload.ServerFileTransferId, TransferDirection.Upload,
channelId, path, channelPassword, upload.Port, upload.SeekPosistion, upload.FileTransferKey, size, createMd5)
channelId, path, channelPassword, upload.Port, (long)upload.SeekPosition, upload.FileTransferKey, size, createMd5)
{ }

public FileTransferToken(Stream localStream, FileDownload download, ChannelIdT channelId,
string path, string channelPassword, long seekPos)
: this(localStream, download.ClientFileTransferId, download.ServerFileTransferId, TransferDirection.Download,
channelId, path, channelPassword, download.Port, seekPos, download.FileTransferKey, download.Size, false)
channelId, path, channelPassword, download.Port, seekPos, download.FileTransferKey, (long)download.Size, false)
{ }

public FileTransferToken(Stream localStream, ushort cftid, ushort sftid,
@@ -42,6 +42,7 @@ namespace TS3Client.Full.Book
using DurationSeconds = System.TimeSpan;
using DurationMilliseconds = System.TimeSpan;
using SocketAddr = System.String;
using IpAddr = System.String;

using Uid = System.String;
using ClientDbId = System.UInt64;
@@ -239,7 +240,7 @@ public Client()
public str CountryCode { get; internal set; }
public ChannelId InheritedChannelGroupFromChannel { get; internal set; }
public str Badges { get; set; }
public ChannelPermissionHint? PermissionHints { get; set; }
public ClientPermissionHint? PermissionHints { get; set; }
public OptionalClientData OptionalData { get; internal set; }
public ConnectionClientData ConnectionData { get; internal set; }
}
@@ -325,7 +326,7 @@ public sealed partial class Server
{
public Server()
{
Ips = new HashSet<SocketAddr>();
Ips = new HashSet<IpAddr>();

}

@@ -352,7 +353,7 @@ public Server()
public str HostbuttonGfxUrl { get; set; }
public str PhoneticName { get; set; }
public IconHash IconId { get; internal set; }
public HashSet<SocketAddr> Ips { get; internal set; }
public HashSet<IpAddr> Ips { get; internal set; }
public bool AskForPrivilegekey { get; internal set; }
public HostBannerMode HostbannerMode { get; set; }
public Duration TempChannelDefaultDeleteDelay { get; set; }
@@ -49,6 +49,7 @@ namespace TS3Client.Full.Book
using DurationSeconds = System.TimeSpan;
using DurationMilliseconds = System.TimeSpan;
using SocketAddr = System.String;
using IpAddr = System.String;

using Uid = System.String;
using ClientDbId = System.UInt64;
@@ -112,6 +113,7 @@ public void UpdateChannelCreated(ChannelCreated msg)
{ var tmpv = ReturnFalse(msg); if (tmpv != null) obj.ForcedSilence = (bool)tmpv; }
obj.IsPrivate = null;
{ var tmpv = ReturnFalse(msg); if (tmpv != null) obj.Subscribed = (bool)tmpv; }
obj.PermissionHints = null;
obj.OptionalData = null;
{ var tmpv = ChannelOrderCcFun(msg); if (tmpv != null) obj.Order = (ChannelId)tmpv; }
{ var tmpv = msg.Name; if (tmpv != null) obj.Name = (str)tmpv; }
@@ -179,6 +181,7 @@ public void UpdateChannelList(ChannelList msg)
}
{ var tmpv = ChannelTypeClFun(msg); if (tmpv != null) obj.ChannelType = (ChannelType)tmpv; }
{ var tmpv = ReturnFalse(msg); if (tmpv != null) obj.Subscribed = (bool)tmpv; }
obj.PermissionHints = null;
obj.OptionalData = null;
{ var tmpv = msg.Name; if (tmpv != null) obj.Name = (str)tmpv; }
{ var tmpv = msg.Topic; if (tmpv != null) obj.Topic = (str)tmpv; }
@@ -255,6 +258,7 @@ public void UpdateClientEnterView(ClientEnterView msg)
{ var tmpv = msg.TargetChannelId; if (tmpv != null) obj.Channel = (ChannelId)tmpv; }
{ var tmpv = AwayCevFun(msg); if (tmpv != null) obj.AwayMessage = (str)tmpv; }
{ var tmpv = TalkPowerCevFun(msg); if (tmpv != null) obj.TalkPowerRequest = (TalkPowerRequest)tmpv; }
obj.PermissionHints = null;
obj.OptionalData = null;
obj.ConnectionData = null;
{ var tmpv = msg.DatabaseId; if (tmpv != null) obj.DatabaseId = (ClientDbId)tmpv; }
@@ -469,7 +473,7 @@ public void UpdateClientPermissionHints(ClientPermissionHints msg)
Log.Warn("Internal Book protocol error. Update 'ClientPermissionHints' has no local object ({$msg})", msg);
return;
}
{ var tmpv = msg.Flags; if (tmpv != null) obj.PermissionHints = (ChannelPermissionHint)tmpv; }
{ var tmpv = msg.Flags; if (tmpv != null) obj.PermissionHints = (ClientPermissionHint)tmpv; }

}

0 comments on commit 7a2434a

Please sign in to comment.
You can’t perform that action at this time.