use of com.almightyalpaca.jetbrains.plugins.discord.data.ReplicatedData in project Intellij-Discord-Integration by Almighty-Alpaca.
the class DiscordIntegrationApplicationComponent method initComponent.
@Override
public synchronized void initComponent() {
try // Fixes problems that crashes JGroups if those two properties aren't properly set
{
Locale locale = Locale.getDefault();
if (System.getProperty("user.language") == null)
System.setProperty("user.language", locale.getLanguage());
if (System.getProperty("user.country") == null)
System.setProperty("user.country", locale.getCountry());
} catch (Exception e) {
e.printStackTrace();
}
try {
String props = "fast.xml";
LOG.trace("DiscordIntegrationApplicationComponent#initComponent()#props = {}", props);
JChannel channel = new JChannel(props);
channel.setReceiver(this);
this.channel = channel;
channel.connect("JetbrainsDiscordIntegration v" + JetbrainsDiscordIntegration.PROTOCOL_VERSION);
ReplicatedData data = new ReplicatedData(channel, this);
this.data = data;
this.instanceInfo = new InstanceInfo(channel.getAddressAsString(), ApplicationInfo.getInstance());
LOG.trace("DiscordIntegrationApplicationComponent#initComponent()#this.instanceInfo = {}", this.instanceInfo);
data.instanceAdd(System.currentTimeMillis(), this.instanceInfo);
RPC.updatePresence(2, TimeUnit.SECONDS);
} catch (Exception e) {
if (this.channel != null) {
this.channel.close();
this.channel = null;
}
if (this.data != null) {
this.data.close();
this.data = null;
}
RPC.dispose();
throw new RuntimeException(e);
}
MessageBus bus = ApplicationManager.getApplication().getMessageBus();
connection = bus.connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerListener());
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener());
EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
multicaster.addDocumentListener(this.documentListener = new DocumentListener());
multicaster.addEditorMouseListener(this.editorMouseListener = new EditorMouseListener());
checkExperiementalWindowListener();
VirtualFileManager.getInstance().addVirtualFileListener(this.virtualFileListener = new VirtualFileListener());
}
Aggregations