1414using System . Collections . Generic ;
1515using System . ComponentModel . Composition ;
1616using System . Diagnostics ;
17- using System . Runtime . Remoting . Contexts ;
18- using System . Runtime . Remoting . Messaging ;
1917using TwicasSitePlugin ;
2018using TwitchSitePlugin ;
2119using WhowatchSitePlugin ;
@@ -40,7 +38,7 @@ public static string ToTextWithImageAlt(this IEnumerable<IMessagePart> parts)
4038 {
4139 s += image . Alt ;
4240 }
43- else if ( part is IMessageRemoteSvg remoteSvg )
41+ else if ( part is IMessageRemoteSvg remoteSvg )
4442 {
4543 s += remoteSvg . Alt ;
4644 }
@@ -53,10 +51,28 @@ public static string ToTextWithImageAlt(this IEnumerable<IMessagePart> parts)
5351 return s ;
5452 }
5553 }
54+ interface ITalker : IDisposable
55+ {
56+ void TalkText ( string text ) ;
57+ 58+ void TalkText ( string text , Int16 voiceSpeed , Int16 voiceTone , Int16 voiceVolume , FNF . Utility . VoiceType voiceType ) ;
59+ }
60+ 61+ [ Serializable ]
62+ public class TalkException : Exception
63+ {
64+ public TalkException ( ) { }
65+ public TalkException ( string message ) : base ( message ) { }
66+ public TalkException ( string message , Exception inner ) : base ( message , inner ) { }
67+ protected TalkException (
68+ System . Runtime . Serialization . SerializationInfo info ,
69+ System . Runtime . Serialization . StreamingContext context ) : base ( info , context ) { }
70+ }
5671 [ Export ( typeof ( IPlugin ) ) ]
5772 public class BouyomiPlugin : IPlugin , IDisposable
5873 {
59- private readonly FNF . Utility . BouyomiChanClient _bouyomiChanClient ;
74+ //private readonly FNF.Utility.BouyomiChanClient _bouyomiChanClient;
75+ private readonly ITalker _talker ;
6076 private Options _options ;
6177 Process _bouyomiChanProcess ;
6278 public string Name => "棒読みちゃん連携" ;
@@ -695,7 +711,7 @@ public void OnMessageReceived(ISiteMessage message, IMessageMetadata messageMeta
695711 }
696712 TalkText ( dataToRead ) ;
697713 }
698- catch ( System . Runtime . Remoting . RemotingException )
714+ catch ( TalkException )
699715 {
700716 //多分棒読みちゃんが起動していない。
701717 if ( _bouyomiChanProcess == null && System . IO . File . Exists ( _options . BouyomiChanPath ) )
@@ -720,21 +736,17 @@ public void OnMessageReceived(ISiteMessage message, IMessageMetadata messageMeta
720736 }
721737 }
722738
723- private int TalkText ( string text )
739+ private void TalkText ( string text )
724740 {
725741 if ( _options . IsVoiceTypeSpecfied )
726742 {
727- return _bouyomiChanClient . AddTalkTask2 (
728- text ,
729- _options . VoiceSpeed ,
730- _options . VoiceTone ,
731- _options . VoiceVolume ,
732- ( FNF . Utility . VoiceType ) Enum . ToObject ( typeof ( FNF . Utility . VoiceType ) , _options . VoiceTypeIndex )
733- ) ;
743+ _talker . TalkText ( text , ( Int16 ) _options . VoiceSpeed ,
744+ ( Int16 ) _options . VoiceTone ,
745+ ( Int16 ) _options . VoiceVolume , ( FNF . Utility . VoiceType ) Enum . ToObject ( typeof ( FNF . Utility . VoiceType ) , _options . VoiceTypeIndex ) ) ;
734746 }
735747 else
736748 {
737- return _bouyomiChanClient . AddTalkTask2 ( text ) ;
749+ _talker . TalkText ( text ) ;
738750 }
739751 }
740752
@@ -763,7 +775,7 @@ public void ShowSettingView()
763775 }
764776 public BouyomiPlugin ( )
765777 {
766- _bouyomiChanClient = new FNF . Utility . BouyomiChanClient ( ) ;
778+ _talker = new IpcTalker ( ) ;
767779 _options = new Options ( ) ;
768780 }
769781
@@ -777,7 +789,7 @@ protected virtual void Dispose(bool disposing)
777789 if ( disposing )
778790 {
779791 }
780- _bouyomiChanClient . Dispose ( ) ;
792+ _talker . Dispose ( ) ;
781793 if ( _bouyomiChanProcess != null )
782794 {
783795 _bouyomiChanProcess . Close ( ) ;
0 commit comments