/// <summary> /// Creates a new instance of <see cref="PluginManager"/>. /// </summary> /// <param name="progress">The progress context for plugin processes.</param> /// <param name="dialogManager">The dialog manager for plugin processes.</param> /// <param name="pluginPaths">The paths to search for plugins.</param> public PluginManager(IProgressContext progress, IDialogManager dialogManager, params string[] pluginPaths) { ContractAssertions.IsNotNull(progress, nameof(progress)); ContractAssertions.IsNotNull(dialogManager, nameof(dialogManager)); // 1. Setup all necessary instances _filePluginLoaders = new IPluginLoader <IFilePlugin>[] { new CsFilePluginLoader(pluginPaths) }; _gameAdapterLoaders = new IPluginLoader <IGameAdapter>[] { new CsGamePluginLoader(pluginPaths) }; _progress = progress; _dialogManager = dialogManager; LoadErrors = _filePluginLoaders.SelectMany(pl => pl.LoadErrors ?? Array.Empty <PluginLoadError>()) .Concat(_gameAdapterLoaders.SelectMany(pl => pl.LoadErrors ?? Array.Empty <PluginLoadError>())) .DistinctBy(e => e.AssemblyPath) .ToList(); _streamMonitor = new StreamMonitor(); _fileLoader = new FileLoader(_filePluginLoaders); _fileSaver = new FileSaver(_streamMonitor, dialogManager); _fileLoader.OnManualSelection += FileLoader_OnManualSelection; _loadedFiles = new List <IStateInfo>(); }
/// <inheritdoc /> public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { await BaseStream.WriteAsync(buffer, offset, count, cancellationToken); if (count > 0) { StreamMonitor.OnWrite(new ArraySegment <byte>(buffer, offset, count)); } }
public UptimeCommand(StreamMonitor streamMonitor) { Name = "!uptime"; Description = "Shows how long the stream has been live"; AlternateName = new List <string> { "!live" }; RequiresMod = false; _streamMonitor = streamMonitor; }
/// <inheritdoc /> public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { var readCount = await BaseStream.ReadAsync(buffer, offset, count, cancellationToken); if (readCount > 0) { StreamMonitor.OnRead(new ArraySegment <byte>(buffer, offset, readCount)); } return(readCount); }
/// <inheritdoc /> protected override void OnNotifySeek(StreamMonitor monitor, long position) { lock (streamLock) { //WriteLine(); lastStreamMonitor = monitor; lastStreamAction = StreamAction.Seek; var content = Encoding.UTF8.GetBytes(position.ToString()); DumpStream.Write(content, 0, content.Length); } }
static void Main(string[] args) { int RoomId = 2064239; Directory.CreateDirectory("plugins"); var files = Directory.GetFiles("plugins", "*.plugin.js"); Log("DMKEngine " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " by Developer_ken"); Log("Loading plugins..."); foreach (string f in files) { try { string loadPath = Path.GetFullPath(f); string fname = Path.GetFileNameWithoutExtension(loadPath); Log("Loading \"" + fname + "\"..."); var js = new JavascriptPlugin(File.ReadAllText(loadPath)); pman.AddPlugin(js); Log("<" + js.Name + "> " + js.Version + " by " + js.Author); } catch (Exception e) { Log("Fail to load plugin " + f, (int)ConsoleColor.Red); Log(e.Message, (int)ConsoleColor.Yellow); Log(e.StackTrace, (int)ConsoleColor.Yellow); } } Log("Initializing engine... "); sm = new StreamMonitor(RoomId, new Func <TcpClient>(() => { return(new TcpClient()); })); sm.Start(); sm.ReceivedDanmaku += Sm_ReceivedDanmaku; pman.TriggerLoad(); JavascriptPlugin interactive = new JavascriptPlugin("" + "plugin.Name='Interactive Console';" + "plugin.Version='0000';" + "plugin.Author='Developer_ken';" + "plugin.NeedLogin=false;"); pman.AddPlugin(interactive); while (true) { try { var result = interactive.RunCode(Console.ReadLine()); Log(result); } catch (Exception e) { Log("Fail to execute:" + e.Message, (int)ConsoleColor.Red); } } }
private void run_CheckedChanged(object sender, EventArgs e) { if (run.Checked) { sm = new StreamMonitor((int)roomnumber.Value, () => { return(new System.Net.Sockets.TcpClient()); }); liveroom = new BiliLiveRoom((int)roomnumber.Value, api); sm.ReceivedDanmaku += Sm_ReceivedDanmaku; sm.Start(); } else { sm.Stop(); } }
/// <inheritdoc /> protected override void OnNotifyWrite(StreamMonitor monitor, ArraySegment <byte> data) { lock (streamLock) { if (lastStreamMonitor != monitor || lastStreamAction != StreamAction.Write) { var tag = GetStreamTag(monitor, StreamAction.Write); //WriteLine(); DumpStream.Write(tag, 0, tag.Length); lastStreamMonitor = monitor; lastStreamAction = StreamAction.Write; } DumpStream.Write(data.Array, data.Offset, data.Count); } }
/// <summary> /// Creates a new instance of <see cref="PluginManager"/>. /// </summary> /// <param name="pluginLoaders">The plugin loaders for this manager.</param> public PluginManager(params IPluginLoader[] pluginLoaders) { _filePluginLoaders = pluginLoaders.Where(x => x is IPluginLoader <IFilePlugin>).Cast <IPluginLoader <IFilePlugin> >().ToArray(); _gameAdapterLoaders = pluginLoaders.Where(x => x is IPluginLoader <IGameAdapter>).Cast <IPluginLoader <IGameAdapter> >().ToArray(); LoadErrors = pluginLoaders.SelectMany(pl => pl.LoadErrors ?? Array.Empty <PluginLoadError>()) .DistinctBy(e => e.AssemblyPath) .ToList(); _streamMonitor = new StreamMonitor(); _fileLoader = new FileLoader(_filePluginLoaders); _fileSaver = new FileSaver(_streamMonitor); _fileLoader.OnManualSelection += FileLoader_OnManualSelection; _loadedFiles = new List <IStateInfo>(); }
/// <summary> /// Creates a new instance of <see cref="PluginManager"/>. /// </summary> /// <param name="pluginPaths">The paths to search for plugins.</param> public PluginManager(params string[] pluginPaths) { // 1. Setup all necessary instances _filePluginLoaders = new IPluginLoader <IFilePlugin>[] { new CsFilePluginLoader(pluginPaths) }; _gameAdapterLoaders = new IPluginLoader <IGameAdapter>[] { new CsGamePluginLoader(pluginPaths) }; LoadErrors = _filePluginLoaders.SelectMany(pl => pl.LoadErrors ?? Array.Empty <PluginLoadError>()) .Concat(_gameAdapterLoaders.SelectMany(pl => pl.LoadErrors ?? Array.Empty <PluginLoadError>())) .DistinctBy(e => e.AssemblyPath) .ToList(); _streamMonitor = new StreamMonitor(); _fileLoader = new FileLoader(_filePluginLoaders); _fileSaver = new FileSaver(_streamMonitor); _fileLoader.OnManualSelection += FileLoader_OnManualSelection; _loadedFiles = new List <IStateInfo>(); }
public PluginManager(IProgressContext progress, IDialogManager dialogManager, params IPluginLoader[] pluginLoaders) { ContractAssertions.IsNotNull(progress, nameof(progress)); ContractAssertions.IsNotNull(dialogManager, nameof(dialogManager)); _filePluginLoaders = pluginLoaders.Where(x => x is IPluginLoader <IFilePlugin>).Cast <IPluginLoader <IFilePlugin> >().ToArray(); _gameAdapterLoaders = pluginLoaders.Where(x => x is IPluginLoader <IGameAdapter>).Cast <IPluginLoader <IGameAdapter> >().ToArray(); _progress = progress; _dialogManager = dialogManager; LoadErrors = pluginLoaders.SelectMany(pl => pl.LoadErrors ?? Array.Empty <PluginLoadError>()) .DistinctBy(e => e.AssemblyPath) .ToList(); _streamMonitor = new StreamMonitor(); _fileLoader = new FileLoader(_filePluginLoaders); _fileSaver = new FileSaver(_streamMonitor, dialogManager); _fileLoader.OnManualSelection += FileLoader_OnManualSelection; _loadedFiles = new List <IStateInfo>(); }
public FileSaver(StreamMonitor streamMonitor, IDialogManager dialogManager) { _streamMonitor = streamMonitor; _dialogManager = dialogManager; }
private void Form1_Load(object sender, EventArgs e) { LogWrite("프로그램이 시작되었습니다"); LogWrite("버전: " + Settings.version); monitor = new StreamMonitor(this); button3.Enabled = false; if (button1.Text == ButtonToggleTextArray[0]) { ProcessIsPause = false; } else { ProcessIsPause = true; } try { //프로그램 경로에 있는 settrings.txt파일 연다. FileStream fs = new FileStream("Settings.txt", FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); //설정값을 파싱 Settings.Refresh = int.Parse(sr.ReadLine()); Settings.UserName = sr.ReadLine(); Settings.Quality = sr.ReadLine(); Settings.Directory = sr.ReadLine(); Settings.ClientID = sr.ReadLine(); Settings.TurnOffAfterRecod = bool.Parse(sr.ReadLine()); Settings.LivestreamerMinimize = bool.Parse(sr.ReadLine()); //대시보드 업데이트 textBox1.Text = Settings.UserName; textBox3.Text = Settings.Quality; textBox4.Text = Settings.ClientID; sr.Close(); LogWrite("설정을 불러왔습니다."); } catch (FileNotFoundException ex) { LogWrite("Settings.txt를 찾을 수 없습니다."); //Settings.txt를 만들고 FileStream fs = new FileStream("Settings.txt", FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); fs.Close(); LogWrite("Settings.txt를 생성하였습니다."); MessageBox.Show("초기설정을 해 주세요"); //설정 대화 상자를 보여주고 Form2 dig = new Form2(); dig.ShowDialog(); //대시보드 업데이트 textBox1.Text = Settings.UserName; textBox3.Text = Settings.Quality; textBox4.Text = Settings.ClientID; dig.Dispose(); } }
protected virtual void OnNotifySeek(StreamMonitor monitor, long position) { Debug.Assert(monitor != null); Debug.Assert(position >= 0); }
private byte[] GetStreamTag(StreamMonitor monitor, StreamAction action) { return(((byte[][])monitor.Tag)[(int)action]); }
public FileSaver(StreamMonitor streamMonitor) { _streamMonitor = streamMonitor; }
public LiveRoom(int roomid, string cookiestr = null) { rid = roomid; sm = new StreamMonitor(roomid, new Func <TcpClient>(Tcpcli), new BililiveAPI(cookiestr)); }
protected virtual void OnNotifyWrite(StreamMonitor monitor, ArraySegment <byte> data) { Debug.Assert(monitor != null); Debug.Assert(data.Count > 0); }